Show object location with arrow

Hi all,
I am making a 3d game, and I want to have a arrow over the player or on my canvas that will point to the location that the player is supposed to go, ex. to an npc. How would I do this?

@unity_23aferg8 Basically what you need to do is:

  1. Calculate the direction from your player position to the target object in the world;

  2. Then you need to check the angle between those two entities: (Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg) % 360 would do the trick;

  3. Then you need to set the UI element (the pointer) eulerAngles (from its transform);

  4. And then make sure to convert the position of the player from WorldToScreen position and se the pointer UI element position to always be on the player or maybe with an offset displacing the element slightly away from the player object.

Or instead of keeping the UI element on the player, you could also force it to be in the target’s position, but clamping its position to never go out side the screen.

CodeMonkey has a video explaining how he approached that.

Hey! Sorry for pinging you here on an old post.
I’m glad I found someone doing this, because I was making something very very similar and I’m curious if you found the solution to this? I can’t wrap my head around on how to do this exactly on code, so any help is much appreciated!