- Home /
Unity 2D Play animation by time event
Hi, my name is Víctor Martínez and I'm new in Game Designing with Unity. I'm trying to make a 2D game and by now I would like to animate a character from an Idle Animation to a 'Wink' animation, to sum up, I'm trying to make my character wink one time by 5 seconds for example.
I have this code, time is the parameter of the transition from 'Idle State' to 'Wink State' and the condition is time greater than 5 but the animation is not accurate.
¿ How can I make the character wink only one time every 5 seconds ?
Animator anim;
public float time = 0.0f;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> (); //Learn about getComponent()
}
// Update is called once per frame
void Update () {
time=time + 1 * Time.deltaTime;
anim.SetFloat ("time", time);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612160828im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to play correct animation based on 2d movement? 3 Answers
Why does my sprite changes position after animation transition? 1 Answer
Animation transition not recognized while holding multiple keys 0 Answers
Animation Problems using 2D Toolkit 2 Answers
How to use multiple bone rigged sprites for 2d character animations 0 Answers