Hi guys this is my first post on unity forum. i really need help on this one
so i made a script that makes my navMeshAgent go to a game object called victim. now my problem is that even if the navMeshAgent reaches the position of the victim. the script wont just stop even though i made it to stop ones its gets to the victim.position.
What i wanted is that when the navMeshAgent reaches victim.position, the script itself would stop.
please help me guys
#pragma strict
public var victim : Transform;
private var navComponent : NavMeshAgent;
var scriptIsActive : boolean = false;
function Start () {
if(!scriptIsActive){
navComponent = this.transform.GetComponent(NavMeshAgent);
}
}
function OnGUI () {
if(!scriptIsActive){
navComponent.SetDestination(victim.position);
}
}
function Update(){
if(navComponent==victim.position)
{
GetComponent(sample2).enabled = false;
}
}