Road kill + sound effects

This commit is contained in:
magn9775
2024-04-20 15:02:09 +02:00
parent 2ceb18470b
commit 601de22cfa
18 changed files with 536 additions and 103 deletions

View File

@@ -4,23 +4,40 @@ using UnityEngine;
public class NPCimproved : MonoBehaviour
{
// Animator animator;
public Animator animator;
public GameObject npcPrefab;
public AudioSource audio;
private bool walking = true;
void Start()
{
}
void Update()
{
if (walking)
{
npcPrefab.transform.position += new Vector3(00,0,0.005f);
}
}
// Disabels the animation controller, to simulate getting hit by car
void OnCollisionEnter(Collision col) {
if (col.gameObject.tag == "Player")
{
animator.SetTrigger("hit");
if (walking)
{
audio.Play();
animator.runtimeAnimatorController = Resources.Load("m_Controller") as RuntimeAnimatorController;
walking = false;
}
}
}
}