Hi Everyone , i use A* Pathfingig 2.5 for my educational project… an enemy look for the player with Run Animation and find you , when enemy is near of your position the animation change to Idle but enemy move position is not stop ! how can i stop the transform enemy(or disable pathfingig) when enemy is near of Player ?
pardon me for bad English text :).
public void Start () {
// Set all animations to loop
animation.wrapMode = WrapMode.Loop;
// Except our action animations, Dont loop those
// animation["shoot"].wrapMode = WrapMode.Once;
// Put idle and run in a lower layer. They will only animate if our action animations are not playing
animation["Idle"].layer = -1;
animation["Idle2Run"].layer = -1;
animation["Run"].layer = -1;
animation.Stop();
}
void Update () {
LenEnemy=(fplayer.position-enemy.position).sqrMagnitude ;
}
public void SetSpeed (float speed) {
if (LenEnemy<100){
animation.CrossFade("Idle");
}
else{
if (speed > minimumRunSpeed) {
animation.CrossFade("Run");
} else {
animation.CrossFade("Idle");
}
}
}
}
[/code]