How to get the object's position?

Hi everyone!
Can you help me to get a particular axis coordinate for my object please? My only result is that the Movement script now dumps the current coordinates to the console.
My idea is to turn off the rocket’s thrusting as it reaches certain height. For that, I am going to compare its current y axis position to the variable I’ve declared and put in serizalizefield earlier. Should be something like

[SerializeField] float maxHeight = 30f;
...
void Update()
{
ProcessThrust();
ProcessRotation();
if (??? > maxHeight)
// The ??? stands here for the current Y axis position.
{
Debug.Log("You raised too high");
}
}

Found it myself.
Should be
if (transform.localPosition.y > maxHeight)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms