- Home /
Idle animation not working
I have a 2d sprite that I'm trying to animate using the demo version of ex2d. I can get movement to work, and I can get an idle animation to work, but I can't get them both working at the same time. This is what I thought would make most sense for getting them both to work, but now only idle animation plays, even if I move left or right.
if (Input.GetAxisRaw("Horizontal").Equals (-1))
{
gameObject.transform.eulerAngles = new Vector3(0, 180, 0);
if (isPlayingAnim==false)
{
spriteAnimation.Play("BG_Moving");
isPlayingAnim=true;
}
}
else if (Input.GetAxisRaw("Horizontal").Equals(1))
{
gameObject.transform.eulerAngles = new Vector3(0, 0, 0);
if (isPlayingAnim==false)
{
spriteAnimation.Play("BG_Moving");
isPlayingAnim=true;
}
}
else if (!Input.anyKey)
{
if (isPlayingAnim==false)
{
spriteAnimation.Play("BG_Idle");
isPlayingAnim=true;
}
}
Any thoughts/help as to how to get this working would be greatly appreciated.
1) Where do you set the "isPlayingAnim" to false?
2) You can live without this: "if (!Input.any$$anonymous$$ey)"
Your answer
Follow this Question
Related Questions
Best way to equip a 2D character? 1 Answer
Animated Overlay Armor Sprite 1 Answer
Running 2D Sprite Animation Once? 2 Answers
How to create animated "sprites" in a 3D environment 1 Answer
Animataion of a Sprite v2 1 Answer