How Do I Change UI Image Anchor Position To Hover Over GameObject?

Hello! I have a 2D game in Unity right now you control with WASD, topown.

I want to have a UI Object on screen during the game, it is just basic text and an image behind it for contrast and it will change throughout the game, but if your character were to walk in the direction the UI is on the screen, eventually when the gameobject comes into view, you’d see the UI lock on the game object, so you know that’s what is speaking etc.

Like being able to hear something from far off, but once you approach it, you can see whats actually talking. you know?

Thanks for reading!

Hi,
When you use canvas overlay, you can convert your game object position to screen position, like this

public Camera mainCamera;
Vector3 screenPosition = mainCamera.WorldToScreenPoint(yourGameObject.transform.position

then with screenPosition, you can use the value to set your UI position (don’t forget to add some values so your UI position are not at middle of your game object).