Look at actor if not on screen

I’m fishing for ideas how to accomplish a button that will rotate at an object if it’s not on screen.

And by this I’d intend to interpolate with current rotation so it’s not a quick snap but more of a turn in direction.

I want to make sure it only works if the actor is not on screen.

Also I need to take in consideration this actor is spawned and destroyed so there will be times it’s not a valid target and I’ll need to look for it by class since it’s not a static world object.

Thoughts?

First get all actors of class, see if that array has some actors (length should be more than 0).

Then get actor world location, translate that location to screen coordinates.
Check if screen coordinates are inside screen 2d box.

There will be cases when only some side is visible, but center is outside of screen. That also can be solved, but its next step.

So when you have basic one check for center of object. Make it more relaxed and check if that center of object is just outside of screen.
If so do series of line traces along that edge of screen. See if one of them hits object.
Its not perfect but most cases should be detected.

Perfect solution would require projecting all vertextes of mesh onto screen plane, and checking if any vertex is in screen.
But i am not sure if you can access all vertex locations of mesh from just blueprints.

I’ve been playing with the first part

Stupid phone… There is a look at node. I’ve use it to change camera to look at object but totally messed up the character as it moves camera but not player. I’ve heard looking in to acontroller for this but not sure it’s exposed to blueprint. I want my player to be turned to face the object as if I’ve spun the mouse to turn at it.

Going to try this.

I’ve gotten the look at ball to work, I Run an event tick that will run the event if the button is pressed. Using an Interpol and only yawl so its not so much an Auto-Aim.