Hi,
I’m currently trying to have an Enemy NPC in my game that try to target/follow player and attack him when close enough.
Right now I have 1 NPC model that have an Animator, a NavMeshAgent & a Ragdoll set properly. I have scripted a damage and ragdoll handler to deal with damages and death. This part is working fine.
I use BlendTrees for various idle and walking states and my animation are not “In Place” so I use OnAnimatorMove to sync the NavMeshAgent velocity on animation time.
Now, my problem: the animations are requiring an amount of time to play until their end and eventually loop (like walk animation). When the NPC is close enough to the player I need to play the attack animation without to wait the walk or idle animation finished so for this I call Animator.CrossFade from my AI script and the attack state have a transition setup to other animations (I only have 1 base animator layer).
Is it the proper way to go ? I mean does calling CrossFade to play animation instantly is good ? (I’m using Unity 5)
I’ve heard this eventually can be handled with animatior layers, but how ?