Moving 8 directions Sprite

Everything is synchronized now

Ok, so I took a look, and from what I can tell moving left, right and up works, while down doesn’t. This can be seen as an error in one of your screenshots ("Unable to play animation “Player Down” since it could not be found). It wasn’t obvious what was wrong really, since the atlas seemed to have the Player Down animation (as can also be seen in the same screenshot).

The tricky thing was that there was a trailing space character at the end of the animation group name, meaning that the animation was actually named "Player Down " <-- not trailing space here. It can be seen when selecting the text:

23

3 Likes

Ok but besides from that if you try to move the character around it’ll let you but if you go up it won’t let you stay on any other idle animation besides up

Isn’t that because out of the four if-elseif cases for the idle animation it is always the first one (up) that evaluates to true? You need to rethink that logic.

1 Like

All of them are set to false though.

Yes, exactly. If you release all keys then self.direction.x and self.direction.y will be set to 0. This means that self.direction.x == 0 evaluate to true. And so does self.direction.y == 0. And you say yourself that self.actions[hash("Up")] == false evaluates to true.

This means that:

 if self.direction.x == 0 and self.direction.y == 0 and self.actions[hash("Up")] == false then
	play_animation(self, hash("idle_up"))

Translates to:

 if true and true and true then
	play_animation(self, hash("idle_up"))

Which leads to it always using “idle_up”.

2 Likes

Any Idea how to fix it