Face object towards a "direction" Crazy Taxi style

Hey everyone,

I have a compass needle that I’ve placed on a separate camera/layer so that it appears as a HUD object.

What I want is for this needle to face the direction that the gravity is set to.

When the player rotates the main camera, the needle should also rotate and point towards the direction of gravity at all times.

I’d also like to know how to do this to, say, the North direction (when the player looks down, the needle should also rotate).

I’ve got this, but it still doesn’t respect the camera’s rotation, only the gravity:

transform.forward = -Physics.gravity;


As I understand it your needle is in a camera separate from your main camera, and therefore by default it’s not affected by your main camera at all because it’s completely separate.

What you want to do is in the Update() function of the second camera with the needle, orbit the camera around the needle by the transform.rotation of the main camera. If you don’t understand what I mean I can probably whip something up really quick to show you.

If you wanted to do this for North instead of gravity you’d just set the transform.forward of the needle to the direction you want to be North. For example

transform.forward = new Vector3(1,0,0);

would point the needle in the positive x direction if you wanted that to be North.