Road kill + sound effects
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user