Hi everyone for today Devlog I’ll share a little thing I made to make an UI element follow you around(I’m using it to show who’s player 1 and 2 but you could use this for dialog bubbles amongst other things)

Well the first thing you need to do is to add a Canvas to the scene and set it up as follows.

Make sure the canvas is set up to Screenspace overlay so it will render over the correct place.

After you add the canvas you can add a text component image or whichever you want to make follow the player.

Just add it as a child of the canvas.

Then add a simple script to the text or image, the script has the character a serialez field so you can publicly set it up, has a serialized offset just in case the object doesn’t show exaclty on top of the character. and the screenposition is only public so you can check out if it’s moving correctly. After that it’s just matter of checking setting the screenposition to Camera.main.WorldToScreenPoint(character transform here) and set up the transform.position to the screenposition + offset and your are all set.

here’s the full code.

here’s the result.



Hopefully this can help you in some way, thanks for reading, if you have any ideas or suggestions give a heads up at carlos@herongames.net , and for updates subscribe to our newsletter also share on twitter or facebook see you next week!