vector to viewpoint with nested rotation

I have a ship which has its own position and rotation and a parent transform object which also has its own position and rotation. This is essential for my game and works really well.

There is just one problem when I want to display the targeting reticle in front of the ship in third person view. This is the code:

public class GUIController : MonoBehaviour
{
    public Transform ReticleFront;

    const float frontReticleDistance = 50f;

    void FixedUpdate()
    {
        //front reticle: get reticle vector based on ship rotation
        Vector3 wantedPos = transform.TransformPoint(0, 0, frontReticleDistance);
        Debug.DrawLine(transform.position, wantedPos, Color.green);

        //front reticle: convert vector to viewpoint position as its a 2d texture
        ReticleFront.position = Camera.main.WorldToViewportPoint(wantedPos);
    }
}

The Debug.DrawLine is drawn with the correct rotation/position but the viewport position of the reticle does somehow seem to ignore the rotation of the parent object.

I would be very thankful for any help.
Greetings :slight_smile:

If changing to LateUpdate fixes things, that’s probably because you’ve got some other behavior also messing with the reticle’s transform (LateUpdate is one of the last functions to run before rendering).