separate sprite's apparent rotation from its transform?

I’m making a little library to help folks used to Scratch get started with Unity (especially Unity 2D).

One trick Scratch does is, each sprite can have any of three different “rotation styles.” This effectively separates the way the sprite is drawn on screen from its logical direction (i.e., the direction the sprite moves when told to move forward). In the “all around” style, the sprite image rotates to face its direction. In “left-right” style, it just flips (mirror across X) for directions that are mostly left, and draws normally for directions that are mostly right. And in “don’t rotate” mode, the sprite image doesn’t rotate or flip at all, regardless of direction.

These modes are really handy.

So now I want to do something similar in Unity. My best thought so far is to just make a separate “direction” property, utterly independent of the transform, and be careful about which code changes the direction vs. mucking with the transform.

But I’m still quite new to Unity’s 2D stuff, so I thought I’d ask… is there something like this already built in?

Thanks,

  • Joe

I don’t think there is, but I guess one could switch out the transform for endering and then set it back after, but that would likelly be a LOT of setting per frame once the object count starts climbing

Yeah, though that’s an interesting idea. But I decided to go with a separate “direction” property that stores a logical direction, separate from the rotation on the transform, and this seems to be working pretty well.