Hey guys i am trying to make my 2d character (Sprite) to Idle in a certain direction
So first i just wanted it to just idle when there was no input so i made this:
if (Velocity.X == 0)
animationManager.Play(animations[“WalkIdle”]);
Thats what i added to my other code i already had just to walk:
if (Velocity.X > 0)
animationManager.Play(animations[“WalkRight”]);
else if (Velocity.X < 0)
animationManager.Play(animations[“WalkLeft”]);
else if (Velocity.Y > 0)
animationManager.Play(animations[“WalkDown”]);
else if (Velocity.Y < 0)
animationManager.Play(animations[“WalkUp”]);
But now my question is How can i let it idle a certain direction??
this is what i made but i didnt work and it just displayed the IdleDown animation the whole time:
if (Velocity.X > 0)
animationManager.Play(animations[“WalkRight”]);
else if (Velocity.X < 0)
animationManager.Play(animations[“WalkLeft”]);
else if (Velocity.Y > 0)
animationManager.Play(animations[“WalkDown”]);
else if (Velocity.Y < 0)
animationManager.Play(animations[“WalkUp”]);
else if (Velocity.Y <= 0)
animationManager.Play(animations[“WalkIdleDown”]);
else if (Velocity.Y >= 0)
animationManager.Play(animations[“WalkIdleUp”]);
else if (Velocity.X <= 0)
animationManager.Play(animations[“WalkIdleRight”]);
else if (Velocity.X >= 0)
animationManager.Play(animations[“WalkIdleLeft”]);
What am i doing Wrong??
please send me code and dont tell me what to do cause my english is pretty bad
No but im like just learning c# and evertime i make a topic people say owh you have to do this and this and that and then im like bro like im just learning please provide me the code instead of just saying you have to add this and this
You’ll learn less by just taking code. If you implement the code yourself from hints given by other people, you will learn a lot more. We can’t, and shouldn’t, do your code for you.
you could use booleans to register you last movement action. so like boolean isLeft = true when you pressed left. and do that for every movement. based on that you know what idle sprite you need to use.