This is the only way I have managed to successfully implement a 3d compass…
I have a compass camera parented to the main camera so it can copy all rotations and movements but only render the compass layer. The compass object is on the compass layer and takes its position, but not rotation from the main camera with the following code…
var compass : Transform;
var cam : Transform;
function Update () {
compass.position = cam.position;
}
It works, but I’m guessing because of the Update function, the compass seems to jitter and lag behind, so the view from the compass camera is not great.
Is there an easier way of achieving a 3d compass, or stopping the camera jitter?
I’m guessing you’re also moving the other camera in some way in the Update() function. If you are, then the position updater is occurring after and before the movement of the camera it’s mirroring. To avoid this, put it in the same script the other camera is moved by at the end of the Update() function. If you can’t do that, try putting it in LateUpdate().
The compass camera is a child of the main camera, so it’s not moved by a script. However the main camera is moved with SmoothLookAt and other scripts. So should I have a look if I can LateUpdate those?
Just another thought here… would it work if you parent the compass to the compass camera and then update its rotation each frame so that it always points “north”? That way the positioning would be handled automatically.
I have actually sorted out the problem, by going through various scripts and changing the way they update… Update, LateUpdate etc… Trial and error, but eventually one of the combinations worked. Now I’m scared to touch it, in case it breaks!