Implement dialogue system
This commit is contained in:
37
Assets/Scripts/Dialogue/PromptDialogue.cs
Normal file
37
Assets/Scripts/Dialogue/PromptDialogue.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user