I would like to show a menu to the right side and at the same y coordinate as a certain gameobject (shown as a green cube in the screenshot).
Therefore I'm trying to get the screen coordinates of the object in my scene using WorldToScreenPoint.
The code I'm using is this:
Vector3 nPos = new Vector3(GlowCube.position.x + GlowCube.localScale.x, GlowCube.position.y, GlowCube.position.z);
Vector3 nOff = Camera.main.WorldToScreenPoint(nPos);
The resulting values however don't look right to me. I have created a red rectangle in order to demonstrate where the coordinates "nOff" would actually be in the screen:
At first I thought I get these strange results because the GlowCube is parented to the case, but since I use GlowCube's world coordinates (GlowCube.postion...) and not its local coordinates (GlowCube.localPosition...), I thought that this wouldn't matter.
What am I forgetting here?
Thank you!