Am trying to create a 3d compass in unity, but the needle fails to rotate/tilt along with the body of the compass. The needle points accurately towards the north "empty gameobject". But the only problem is it fails to tilt/rotate(up or down) along with the compass body. Below is d script
public class AmpCompass : ResetObject
{
public Transform target, compassNeedle;
public float speed = 1.0f;
private void Start() {
}
protected override void ObjectIsGrabbed()
{
base.ObjectIsGrabbed();
}
private void Update()
{
Vector3 needleDir = new Vector3(target.position.x, compassNeedle.position.y, target.position.z);
compassNeedle.LookAt(needleDir);
}
}