Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class IACircuito : MonoBehaviour {
- NavMeshAgent navAg;
- GameObject pos1;
- GameObject pos2;
- GameObject pos3;
- GameObject pos4;
- GameObject pos5;
- Vector3 target1;
- Vector3 target2;
- Vector3 target3;
- Vector3 target4;
- Vector3 target5;
- Vector3 targetx;
- void Awake(){
- navAg = GetComponent<NavMeshAgent> ();
- pos1 = GameObject.FindGameObjectWithTag("Posizione1");
- pos2 = GameObject.FindGameObjectWithTag("Posizione2");
- pos3 = GameObject.FindGameObjectWithTag("Posizione3");
- pos4 = GameObject.FindGameObjectWithTag("Posizione4");
- pos5 = GameObject.FindGameObjectWithTag("Posizione5");
- target1 = pos1.transform.position;
- target2 = pos2.transform.position;
- target3 = pos3.transform.position;
- target4 = pos4.transform.position;
- target5 = pos5.transform.position;
- }
- void Start(){
- targetx = target1;
- navAg.SetDestination(targetx);
- }
- void OnTriggerEnter(Collider col){
- if(col.tag==("Posizione5")){
- targetx = target1;
- navAg.SetDestination(targetx);
- } else if (col.tag == ("Posizione4")){
- targetx = target5;
- navAg.SetDestination(targetx);
- } else if (col.tag == ("Posizione3")){
- targetx = target4;
- navAg.SetDestination(targetx);
- } else if (col.tag == ("Posizione2")){
- targetx = target3;
- navAg.SetDestination(targetx);
- } else if (col.tag == ("Posizione1")){
- targetx = target2;
- navAg.SetDestination(targetx);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement