This commit is contained in:
shakurass 2014-04-26 15:26:45 -06:00
commit 4308538814
6 changed files with 95 additions and 113 deletions

14
Assets/Scripts/Driver.cs Normal file
View file

@ -0,0 +1,14 @@
using UnityEngine;
using System.Collections;
public class Driver : MonoBehaviour {
Vector3 dest;
void Awake() {
Vector3 pos = GameObject.Find("node3").transform.position;
NavMeshAgent nva = GetComponent<NavMeshAgent>();
nva.SetDestination(pos);
nva.updateRotation = false;
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aa1e6a2eca2f44c56a92f8128e0a7d43
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,10 @@
using UnityEngine;
using System.Collections;
public class NavPoint : MonoBehaviour {
void OnTriggerEnter(Collider other) {
Patron p = other.gameObject.GetComponent<Patron>();
if(p != null)
p.NextDest();
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 79de31dde1348491f8c7da34e162f0e7
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -3,13 +3,24 @@ using System.Collections;
public class Patron : MonoBehaviour {
Vector3 dest;
public GameObject[] destinations;
public int currentDestIndex = 0;
private NavMeshAgent nva;
void Awake() {
Vector3 pos = GameObject.Find("node3").transform.position;
NavMeshAgent nva = GetComponent<NavMeshAgent>();
nva.SetDestination(pos);
nva = GetComponent<NavMeshAgent>();
nva.updateRotation = false;
nva.SetDestination(destinations[0].transform.position);
}
public void NextDest() {
if(currentDestIndex + 1 < destinations.Length)
++currentDestIndex;
else
currentDestIndex = 0;
nva.SetDestination(destinations[currentDestIndex].transform.position);
}
void OnTriggerEnter(Collider other) {