Make Screen Space - Overlay UI follow player (3D game)

Hey there,

I created a gauge for my player that should appear next to my player when collecting certain items. It works well except one part : I can’t manage to make it follow the player without it being janky.

How can I do this ?

Here’s how I did it so far :

private void SetPosition() {
    Vector3 screenPos = pl.mainCamera.WorldToScreenPoint(pl.transform.position);
    rTransformUI.position = Vector3.SmoothDamp(rTransformUI.position, screenPos, ref velocity, smoothTime);
  }

It kinda smoothes it, but the smooth is WAY too slow and changing smoothTime doesn’t seem to impact it at all.

Prior to that, I had this (which was very janky, no matter if I called that in LateUpdate, FixedUpdate or Update) :

rTransformUI.position = screenPos

Thanks for the help ! :slight_smile:

I had another idea though : to use a world space UI. But then the issue is, I want its size to be bound (so that it’s not minuscule when the player is too far away and too big when he’s too close to the camera).

I’m not sure how to do this scaling ?