Hello,
I want to have a UI attached to a GameObject. This UI is within a world-space canvas that’s child to the GameObject.
My goal now is that, no matter from where the player is looking at the GameObject, the canvas is also always positioned above and right from that GameObject.
It must be very simple, so maybe someone can help.
// Same spot no matter the viewing angle
UI.transform.position = worldObject.transform.position + new Vector3(howFarUp, howFarRight, 0);
// Different spot depending on which direction the worldObject is facing
UI.transform.position = worldObject.transform.position + (worldObject.transform.up * howFarUp) + (worldObject.transform.right * howFarRight), 0);
// Different spot depending on which direction you look at the object from
UI.transform.position = worldObject.transform.position + (player.transform.up * howFarUp) + (player.transform.right * howFarRight), 0);
1 Like