I want to implement this feature in my game. The images are just examples to give the idea.
Imagine a top down racing game. When your opponent is out of the screen I want to make some kind of arrow to show where the opponent is. As soon as the opponent is visible on the screen, the arrow disappears.
When the opponent is far away from the player:
(The arrow also can be on the left side or the right side of the screen as well)
I suspect what the OP is stuck on is how to position & aim the arrow so that it accurately points towards a specific off-screen object.
This tutorial was the first hit in my Google search and looks reasonably good, although from a skim I’m not sure they’re paying quite enough attention to some special cases that exist in 3D but not in 2D. (In particular, when the target point is behind you in 3D, then its projection onto the 2D plane of your screen might be within the screen bounds even though the object is off-screen.)