- Home /
A Prefab with animation.Play doesnt work
Hi, I made a simple model using maya and exported as a FBX. It basically had two sets of animation , one is a walk sequence and the other a hit sequence. I made this model an enemy prefab, so that I could instantiate it, and set all the animation parameters in unity with an animation script attached. The problem is, if I drag and drop the original fbx model in the inspector, attach the same animation script and run the game the animations, both walk and hit, play correctly. But if I drag and drop the enemyPrefab the animation doest seem to work.I have searched but I have not found an answer. Can you please help me with it. I apolozise if this has been asked before. I have tried with Crossfade and Play with the prefab but to no avail.
script c#:
if (Vector3.Distance(objPlayer.transform.position,objEnemy.transform.position)<10.0f) { objEnemy.animation.Play("eHit"); } else { objEnemy.animation.Play("eWalk"); }
Cheers wolfhammer
Your answer
Follow this Question
Related Questions
Importing Animation With @ Naming Method-File Size 1 Answer
Can I make animations snap to a frame? 1 Answer
Why Mel Scripted Animation Won't Play in Unity 1 Answer
How to export FBX at runtime with animation(s), rig and the mesh to Maya, blender etc.. ? 1 Answer
Can't add components to imported FBX 1 Answer