He there!
I have a nav mesh agent attached to an enemy who chases me with a looping WALK cycle animation. When I hit him with a projectile, he reacts with another 2-second animation called SLAP.
Unfortunately during the SLAP animation, my enemy keeps floating toward me. Any way to make the nav mesh agent pause for 2 seconds?
This is my Nav Mesh AI javascript, also attached to the enemy:
var target : Transform;
function Update()
{
GetComponent(NavMeshAgent).destination = target.position;
}
This is my C# code attached to the enemy that changes the animation:
using UnityEngine;
using System.Collections;
public class AnimChange : MonoBehaviour
{
private Animation _animation;
void Awake()
{
_animation = GetComponent<Animation>();
_animation["slap"].wrapMode = WrapMode.Once;
}
void OnCollisionEnter(Collision col)
{
_animation.Play("slap");
_animation.PlayQueued("walk");
}
void OnTriggerEnter (Collider other)
{
Animation anim = GetComponent<Animation>();
anim["slap"].wrapMode = WrapMode.Loop;
}
}
Thank you so much if you can help!