Files
Scampz/Assets/Scripts/Dialogue/PromptDialogue.cs
2022-08-17 02:10:27 -07:00

38 lines
898 B
C#

using Scampz.GameJam.Assets.Scripts;
using UnityEngine;
namespace Scampz.GameJam
{
public class PromptDialogue : MonoBehaviour
{
[SerializeField]
private DialogueTrigger _dialogueTrigger;
private bool _isWithinRange = false;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
_isWithinRange = true;
}
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
_isWithinRange = false;
}
private void Update()
{
if (_isWithinRange && Input.GetButtonDown(InputOptions.Submit) && !DialogueManager.Instance.IsTalking)
{
var player = GameObject.FindGameObjectWithTag("Player");
var cc = player.GetComponent<CharacterController>();
cc.enabled = false;
_dialogueTrigger.TriggerDialogue();
cc.enabled = true;
}
}
}
}