1
0
forked from cgvr/DeltaVR

npcs turn towards the player separately from being aggroed

This commit is contained in:
2026-03-12 18:57:30 +02:00
parent a6a6b036ca
commit fc083e7d81
9 changed files with 100 additions and 15 deletions

View File

@@ -121,14 +121,14 @@ public abstract class NPCController : MonoBehaviour
currentVoicelineEvent.release();
}
public void PlayerApproach(Transform player) {
playerTransform = player;
public void PlayerApproach() {
OnPlayerApproach();
}
public void PlayerLeave()
{
playerTransform = null;
OnPlayerLeave();
}
@@ -136,6 +136,22 @@ public abstract class NPCController : MonoBehaviour
protected virtual void OnPlayerLeave() {}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player Head")
{
playerTransform = other.transform;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player Head")
{
playerTransform = null;
}
}
public void SpeakVoiceLine(int voiceLineId, GameObject emitter = null, float radioAmount = 0f)
{
if (voiceLineId < 0 || voiceLineId >= voiceLineKeys.Length)