Sprite Flip Script

Hii,

Im working on a new game, but thought it might be nice to post scripts I make//find for my project here to share… First script is a sprite flip script that unbinds the entity from your mouse. Makes your sprite turn left and right when inputs are added rather than relying on mouse direction.

3 Likes

I did the same for my current project as well but I use 8(dead-space) instead of 0 because sometimes when the unit stops moving it flickers left/right.

3 Likes

So, in your picture,
horizontally” sprite is one for unit facing rightward,
while “none” is for one facing leftward.

And the direction where a unit faces changes according to velocity, or which way it is moving right now, rather than player mouse position or the direct key inputs by the player.

If it is moving right, the sprite shows a unit moving right.
While, if it is moving left, the sprite shows a unit moving left.

Even if the player is pressing down left key to cancel the unit’s speed rightward, the unit still looks moving rightward until it stops.

That is true, would love feedback if you have any adjustments that would fix that.

1 Like

After consideration, I think it’s the best way to represent a human unit’s facing direction.
When a human tries to turn around, we first need to stop, and then flip ourselves, starting to move the other way. Which means when we are deaccelerating to rotate ourselves, we are still forwarding the same direction as we were. Why I clarified the behavior of your script was when several people complained about it, I could swiftly answer to the question by providing them with it. Probably it’d be nice if I found other ways, especially “rotation on inputs”, so I’ll do that once I’m motivated.