- Home /
Animation Parameters
I am very confused with animation parameters is it as easy as making a boolean then saying
if(Input.GetButton("Fire1"))
animator.SetBool("Jump", true );
}
else
{
animator.SetBool("Jump", false);
}
and it automatically plays the jump animation or is there more to know?
Answer by BilboStabbins · Feb 15, 2013 at 06:12 PM
From your code, what you're trying to achieve would go more like:
if(Input.GetButton("Fire1"))
{
animation.Play("jump")
}
If the WrapMode of the jump animation is set to Once, then it will only play once when you press the fire button. So you don't need the else condition. You can add a condition before it plays to wait until an animation has finished playing before starting another, but if just starting out I would learn the basics first.
Animation Reference: http://docs.unity3d.com/Documentation/ScriptReference/Animation.html
Example Projects: http://unity3d.com/gallery/demos/demo-projects (the 3D Platformer tutorial is a good one to start learning about animations)
Hope that helps.
Answer by MerchDev · Dec 20, 2013 at 02:28 PM
The code you wrote above changes the value of the boolean animation parameter "Jump" to true/false. In order for you animation state machine to transition from it's current animation state (idle or walk or whatever) to the jump state, you need to have a transition from that state to the jump state where the condition is "Jump" equals "true".
Your answer
Follow this Question
Related Questions
Parameter walk does not exist 0 Answers
Play animation while button is pressed fails when using boolean parameters. 1 Answer
Running animation is rotating the character, why? and how to stop? 0 Answers
How to play a destroy animation? Brick Breaker/Arkanoid. 1 Answer
Create animation transitions via script. 0 Answers