Issue with my vehicle asset (front/back)

I’m using different assets for my game and I faced the following issue: Unity sets front arrow to my sprite’s actual back, so my vehicle moves backwards in play mode:
vehicleBackwards

I put minus to the variable standing for vertical movement (the same way as we did in lecture Using Input.GetAxis() for horizontal axis)

float moveControl = Input.GetAxis ("Vertical") * moveSpeed * Time.deltaTime;
        transform.Translate(0, -moveControl, 0);

With this code it moves correctly now.

But I wonder if there’s another solution to that? Is it possible to somehow adjust my sprite itself? When I change its rotation Z value it rotates accordingly in the scene, but coordinates (arrows) remain the same, glued to the back:
vehicleBackwards_0vehicleBackwards_180

Of course I can rotate the image in Photoshop and re-upload it to Unity. However I’d like to know, if there is a proper way to solve this inside Unity (i.e. to set front arrow to whichever side of my sprite I want)?

Btw sorry if my English is not perfect, tried my best

Hi Morra,

The best would be to rotate the sprite in Photoshop (or GIMP). You do not have to reimport the file. Just open the file in your Assets folder.

If that’s not possible, create a child game object in Unity. Reset the Transform of the child. Move the Sprite Renderer component to the child. Rotate the child by 180°.

Move the parent via code.

Did this help?


See also:

Wow, yes, now with a parent-child trick the arrows are displayed correctly :star_struck:
Thank you, Nina!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms