uppy
uppy

Reputation: 249

World Space Canvas not showing in Game

I have a 2D game and I need a nameplate above the player.

I've got it all working, but it only shows up in the editor and not the game.

I'm sure it's something to do with the camera rendering above it but I don't know how to fix it.

The Canvas is set to the UI layer so that's not the issue.

The Inspector:

Canvas inspector properties

In-Editor

enter image description here

In-Game:

enter image description here

Upvotes: 0

Views: 7996

Answers (1)

Programmer
Programmer

Reputation: 125275

When you change the Canvas's Camera mode from Overlay to World, it resets its RectTranform z, y, z position value.

You have to set the x and y axis to 0. After that you must move the z axis forward so that the Canvas will be positioned in front of the Camera. It is likely behind the camera. So if the camera's z-axis pos is about -10, you have to move the canvas z-axis forward to about 460.The distance to move it actually depends on the distance of the Camera's z-axis.

Remember that the Canvas is now in world space which means that it can be in front of other objects, back of them or in the middle of any them. You have to continue to modify the z-axis until you get the right position where nothing is blocking it. The easiest way to do this is to click the Pos-Z axis then drag it with the mouse as demonstrated below..

Upvotes: 3

Related Questions