Search code examples
c#unity-game-enginevirtual-reality

How do I maintain a canvas always above a game object?


I'm making a vr game, some of my game objects have a world space canvas displaying the game object's info.enter image description here

When I'm holding the game object upright like this, it looks fine, but if I rotate it downwards, the canvas will follow the parent.

enter image description here

As shown here the canvas which is a child of the game object follows the parent and ends up at the bottom. I want it to always be above the game object

Heres the hierarchy of game objects

enter image description here

finally my canvas has this lookat cam script enter image description here


Solution

  • I think you should rotate only "Salt Shaker Obj" (assuming it's GameObject with renderer) instead of entire "Salt Shaker". Or if it's necessary to rotate parent object then introduce another empty GameObject as parent of "Salt Shaker" and place canvas as "Salt Shaker" sibling.