Freeze a sprite's rotation

Hi,

I’m developing a 2D isometric game. Currently, when I move one of my sprites, it turns paper-thin, becoming nearly invisible. Let me illustrate:

19265-2drotation.png
Here is my game sprite.

19266-2drotation2.png
Here is what happens after issuing a move order. The sprite becomes paper-thin, because it wants to rotate downwards.

To fix this, I’d like to freeze my sprite’s rotation, but can’t seem to figure out how.

I tried setting rigidbody.freezeRotation = true in the Start() method, but it had no visible effect.

Thanks in advance!

It looks liks you're using NavMesh with a top-down camera view. If so, you can have an empty GameObject with the nav mesh attached with a zero'd out rotation, then have your character sprite 90' rotated towards the camera.

–

I'm not sure what a NavMesh is, but I was able to fix the issue by getting rid of my transform.LookAt call. Now I've got a different issue with not being able to tell which way the unit is 'facing', but I'll ask a more specific question in a new thread. Thanks for the input!

–

1 Answer

1

What you can do is set the sprite to be billboard. Billboard means that is always faces the camera, so it can never be paper thin. Here’s the code, just attach this script to the object you want to be always visible :

public class BillboardSprite : MonoBehaviour {
	void Update () {
		transform.LookAt(Camera.main.transform.position,

-Vector3.up);
}