I wonder how engine decide to use left and right animation when character moving diagonal. I changed the if elseif order to see whether it depens on it or not, but it remained the same. So I want to understand it. Anyone explain?
Well, it should be the order in update which decides which animation to use:
if self.dir.x > 0 then
anim = hash("right")
elseif self.dir.x < 0 then
anim = hash("left")
elseif self.dir.y > 0 then
anim = hash("back")
elseif self.dir.y < 0 then
anim = hash("front")
end
If you check self.dir.y before checking self.dir.x it should prioritize the back and front animations.
2 Likes
I tested it but results was the same. Maybe I did something wrong. I’ll check it again later. Thanks for the reply.
I think it is to do with the hash order.
Hold down the up and down arrows at the same time and the player always goes down. Swap the two strings (“up” and “down”) in the player script, and in the input binding, and the player always goes up. This is what happened for me in a different tutorial, with the same sort of coding.
2 Likes