add basic dialogue system and interactable interface

This commit is contained in:
2025-06-20 22:55:51 -05:00
parent 33bf1663aa
commit 08dcb7c019
108 changed files with 62960 additions and 1167 deletions
+36
View File
@@ -4,6 +4,8 @@ public class PlayerController : MonoBehaviour
{
public GameObject DougBody;
public float walkSpeed;
Interactable nearestInteractable;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
@@ -16,6 +18,7 @@ void Update()
{
RotatePlayerTowardMouse();
Walk();
TryInteract();
}
void Walk()
@@ -33,4 +36,37 @@ void RotatePlayerTowardMouse()
DougBody.transform.rotation = Quaternion.Euler(new Vector3(0f, -(angle + 90), 0f));
}
void TryInteract()
{
if (Input.GetKeyDown(KeyCode.E) && nearestInteractable != null)
{
nearestInteractable.Interact();
}
}
private void OnTriggerEnter(Collider other)
{
Interactable interactable = other.GetComponent<Interactable>();
// store nearest interactable if it exists
if (interactable != null)
{
nearestInteractable = interactable;
interactable.MoveInsideRange();
}
}
private void OnTriggerExit(Collider other)
{
// just null out interactables when we leave an interactable trigger (we cant and shouldn't overlap interactables)
Interactable interactable = other.GetComponent<Interactable>();
// store nearest interactable if it exists
if (interactable != null)
{
nearestInteractable.MoveOutsideRange();
nearestInteractable = null;
}
}
}