Hello,
actually when my unit spawns, it goes straight to the Enemy's base to destroy it, but on it's way to there: it has to kill Enemies first! instead of killing the enemies, it goes straight to the base, because the enemies are spawning after the Enemy's base
So the Enemy's base is the first object on the NavMesh... I am stuck...
I want the unit's to "see" the Enemy if it's spawned, when the unit is Walking in a Radius of the Enemy
my Code actually:
using UnityEngine;
using System.Collections;
public class PlayerFindEnemy : MonoBehaviour {
Transform enemy;
NavMeshAgent nav;
void Awake ()
{
enemy= GameObject.FindGameObjectWithTag ("Enemy").transform;
nav = GetComponent ();
}
void FixedUpdate() {
nav.SetDestination (enemy.position);
}
}
This is my code,
can I do anything like a "Refresher to activate the NavMesh - if in Range/Distance again" ?
Thank you for reading
↧