Hey guys
I got a Problem with playing my walk animation.
I programmed an AI which follow me if I’m 10 meters away from it.
And it stops walking when it’s nearlyer than 10 meters to me.
And here is my problem :
My AI play the Animation Walk(In script called Take)When I’m 10 meters away.If im nearlyer than 10 meters it stops playing the walk animation and that’s right but now when I’m again 10 meters away it don’t start the walk animation again
please help me
here’s my code
protected void Walk (Vector3 targetPosition){ //***
Vector3 velocity;
Vector3 moveDirection = transform.TransformDirection(Vector3.forward);
Vector3 delta = targetPosition - transform.position;
if(delta.magnitude > minimalDistance)
{
velocity = moveDirection.normalized * movingSpeed * Time.deltaTime;
characterAnimationState = AnimateState.Take;//**::
}
else{
velocity = Vector3.zero;
animation.Stop ();
}
rigidbody.velocity = velocity;
}