HOW TO CENTER LIFEBAR TO PLAYER'S POSITION IN A SPHERE MAP?

Hi, i’m developing a game that is a sphere world map. My problem is that when I try to center player’s lifebar, the canvas is not centering the lifebar relative to player position.

I’m using this code (from X-Bars Assets) but, i dont know why, lifebar is setting to extremelly left bottom.

HealthbarPrefab.transform.position = cam.ScreenToViewportPoint(new Vector3(thisT.position.x, thisT.position.y + yOffset, thisT.position.z));

Can someone help me with this?

Just ’ more information, my canvas is render mode = screen space - overlay and canvas scaler is scale with screen size 800 x 600

Hello!

First, are you sure this “HealthbarPrefab” is the instantiated object in the scene?? Or is a prefab stored in assets folder? You need to update the position of the instantiated object in the scene!

And this code gives 0 info to us… 0 context, no inpector screenshot, no scene screenshot…

When this line is executed, makes the (0,0,0) of the HealthbarPrefab transform to be at (0,0,yOffset) relative to “thisT” object…

CAnvas mode is not related, as the object is in a worldposition and related to a misterious object called “thisT”…

Bye.