Get global Y position of object C#

Making a flight sim, basically, but I need to have a variable for my global vertical position for a planned gameplay feature. I’ve tried using:

Vector3 Altitude = transform.position;

and this seems to work. However, when printed into the debug log, it always comes out with three values; x, y and z rather than just the required Y variable.

Is there a way to grab just this value from the existing code, or is there a simpler way?

I’m a code newbie, but learning >.>

You can pull out the y component of the vector…

float altitude = transform.position.y;

transform.position.y

Isn’t it? This also works for every coordinate and for every Euler angle

.