44 lines
892 B
C#
44 lines
892 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class NPCimproved : MonoBehaviour
|
|
{
|
|
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")
|
|
{
|
|
if (walking)
|
|
{
|
|
audio.Play();
|
|
animator.runtimeAnimatorController = Resources.Load("m_Controller") as RuntimeAnimatorController;
|
|
walking = false;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|