- Home /
Question by
JeppeNygaard · Aug 08, 2012 at 07:25 PM ·
navmeshagentpathfindingfunction call
prober use of navmeshagent.stop()?
I would like to be able to call a function that stops a NavAgent where ever it is on it's path. I assume I need to use the function navmeshagent.stop, but I can't seem to use it correctly ... this is what I have so far: (see the function called StopAttacking)
can someone push me in the right direction?
Thanks, Jeppe
.......
var target : Transform;
var Attack : boolean;
private var NavComponent: NavMeshAgent;
function Start () {
NavComponent = this.transform.GetComponent(NavMeshAgent);
}
function Update () {
if (Attack){
NavComponent.SetDestination(target.position);
}
}
function setStopDist (stopDist:float) {
NavComponent.stoppingDistance =stopDist;
}
function StopAttacking(){
NavComponent.Stop();
}
function readyToAttack (status : boolean) {
Attack = status;
}
Comment