- Home /
Best Way to script Mecanim Animation CrossFade?
I want to script a shooting animation.
There are two animations for this which is Idle and Fire.
This is my script:
var PlayerAnimator : Animator
if(Input.GetMouseButtonDown(1))
{
PlayerAnimator.CrossFade("Fire",1);
}
else
{
PlayerAnimator.CrossFade("Idle",1);
}
I am also a bit unsure about the Crossfade as in how the value will affect the transition.
I'm also really interested to know. I've used unity for a long time but this is my first time importing animations. What if I've broken the animations up into individual files. Will the crossfade work? Over what time does the cross-fade take to complete a transition?
If you are using mecanim you need to make sure its setup correctly in the animator window of mecanim, make sure the correct animator is setup, and then apply the changes in script using values you setup in mecanim. You are trying to use the legacy scripting for mecanim system. Youd set up a boolean in mecanim animator and isIdle bool true, if clicked, mecanim will make the tranistion and the else will throw it back once changed to false. The type of script line you are aftrr would be AnimatorName("booleanName", false). Animator name being the linked animator and the booleanName being the boolean you created in the mecanim animator window. Its kind of hard to explain in one comment post I'll try to find a good tutorial. You dont have to use booleans you can use floats or whatever.
Your answer
Follow this Question
Related Questions
Blender animations to Unity problems 0 Answers
blender animations problem (or bug) in mecanim 0 Answers
Animator System doesnt work! 1 Answer
Animation Events and Mecanim 0 Answers
What is the proper way to wait for an Animator Controller to update? 1 Answer