PLEASE HELP!! Grow tree tall and short (Animation) Cannot reverse the growing animation
this is what im trying to achieve,
if i press the up-arrow, the tree grows taller (10 foot)
if i press the down-arrow, the tree grows shorter (1 foot)
now suppose it has grown 5 feet tall, on pressing the down arrow, how can i make it short by reversing the animation.
Here is my code:
using UnityEngine; using System.Collections;
public class PlayerManager : MonoBehaviour { Animator anim;
void Start ()
{
anim = GetComponent<Animator> ();
}
void Update ()
{
//--------------------------Expand---------------------------------------- if(Input.GetKeyDown(KeyCode.UpArrow)) { anim.SetInteger("State",1);
anim.enabled = true; }
if(Input.GetKeyUp(KeyCode.UpArrow))
{
anim.SetInteger("State",0);
anim.enabled = false;
}
//-------------------------Contract--------------------------------------- if(Input.GetKeyDown(KeyCode.DownArrow)) { anim.SetInteger("State",2);
anim.enabled = true; } if(Input.GetKeyUp(KeyCode.DownArrow)) { anim.SetInteger("State",0);
anim.enabled = false;
}
}
}
Note: The animation sprite i created is of the tree growing tall upto 19 frames.
Your answer
Follow this Question
Related Questions
The animation still counting,The animation keeps counting 0 Answers
Why is my animation (animator) delayed ? 1 Answer
Simple call animation then destroy? 0 Answers
Animator not initialized "cautions" 0 Answers