Any idea on scripting horizon indicator / aoa indicators

Hi does any one have any idea on how to implement horizon indicators reference image attached.

I would like to make the horizon indicator have zero rotation even if the canvas is rotating with the camera.

There’s a lot of fiddling required to get these pitch ladders / situational indicators to feel right.

Attached is a simple attitude indicator ball I made.

I’m also working on a full pitch ladder for my Jetpack Kurt game but I’m not happy with the results yet.

3476842–276371–AttitudeIndicatorExample.unitypackage (86.3 KB)

1 Like

Solved

Thanks i checked
your project actually you are working with the attitude indicator ball in 3d but im trying to make a hud which is on a canvas and getting the rotation of the plane in 3d but tinkering around for a while i managed to get it right i dont think its the most efficient way to do it but it works Here is the code:

Ip_aeroplane_Controller aeroplaneController;
    RectTransform rectTransfrom; //rect transform of pitch ladder
    public Camera playerCam; // player camera
    public RectTransform HorizonLine; //horizon Line
    public int horizonMultiplier=55; // 55 worked well when the plane rotated for me

    void Start()
    {
        rectTransfrom = transform.GetComponent<RectTransform>();
        aeroplaneController = FindObjectOfType<Ip_aeroplane_Controller>();
    }


    public void FixedUpdate()
    {
      
        Vector3 velocityVector = aeroplaneController.transform.position + aeroplaneController.transform.forward* 200f ; // get a position in front of the plane
      
        rectTransfrom.position = playerCam.WorldToScreenPoint( velocityVector); // change pitch ladder position on screen
        HorizonLine.position = playerCam.WorldToScreenPoint(velocityVector); // move horizon line to center on pitch ladder

        Vector3 negativeAircraftRotation = -(aeroplaneController.transform.rotation).ToEuler(); // get negative rotation of player plane to rotate the horizon against the plane rotation
        Vector3 lastRotation = new Vector3(0, 0, negativeAircraftRotation.z*horizonMultiplier); // calculate the rotation on z axis
        HorizonLine.rotation = Quaternion.Euler(lastRotation); // rotate the horizon line

    }

1 Like