Merge branch 'master' of ooftooft.net:Racesm
This commit is contained in:
43
Assets/Scripts/NPC improved.cs
Normal file
43
Assets/Scripts/NPC improved.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/NPC improved.cs.meta
Normal file
11
Assets/Scripts/NPC improved.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cf5c39eb580998489213d03ff8a6760
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -12,6 +12,8 @@ public class carcontrolv2 : MonoBehaviour
|
||||
|
||||
public float autoBrake;
|
||||
|
||||
public AudioSource audio;
|
||||
|
||||
WheelControl[] wheels;
|
||||
public Rigidbody rigidBody;
|
||||
|
||||
@@ -107,4 +109,13 @@ public class carcontrolv2 : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnCollisionEnter(Collision other) {
|
||||
|
||||
if (other.gameObject.tag == "Wall")
|
||||
{
|
||||
audio.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user