I’ve seen various requests for how to calculate the screen x,y coords of an off-screen object and the point on the edge closest to it – using Blueprints.
I saw them because I was looking for a way to do it and didn’t like what I found, so I’ve made my own and I hope this will help others.
Below is a sample of it in use, and the blueprint screengrab below that:
It returns the point on the edge of the screen that’s between the center of the screen and the target point if you draw a straight line in 3D space between the two. It also takes a margin (0 = no margin, 1 = center of screen, 0.5 = half way between those) if you don’t want to use the actual screen edge for whatever reason. It should cope with different screen resolutions and aspects without any trouble.
It also returns the float angle in degrees heading towards the target – used above to orient the arrows.
Edit: There should be an ABS node in “Use resulting screen coord to find screen edge and angle”, just after the first “+” node. Of course I discovered it immediately after posting this. D’oh.