How To Get Stationary Object To Keep Focus On Player

How can I get a stationary object/ Static mesh to keep focus on a player? For example a security camera. I need it to follow the player as they are roaming around the room. But I don’t want it follow them around I just want it to follow the players movement.

I hope the wording is not too confusing. I’m having a hard time finding the right words and so I’m also having a hard time finding a tutorial on such a thing.

I’m using v 4.17


You can make an Actor blueprint, add the static mesh to it and implement the following logic in its Event Graph:

Make sure that your mesh’ is facing towards ‘X’ axis of the local blueprint coordinate system. If your map is large or you have too many of these and you don’t want them to tick all the time, then you can either create a Timer and activate it whenever player enters that area (using a trigger volume and the overlap event) or start these actors with tick disabled, and activate the tick only after the player steps into the overlap box that you placed somewhere in your map.

Hope this helps :slight_smile:

First of all, thank you for taking the time to help ! this looks good and seems to work but I’m having an issue… The mesh isn’t following the players movement. It does get triggered and it flips around but it doens’t follow my movement. Is this done correctly or no?

AH… Whoops. I’m still learning lol. Okay, now it’s working. It’s rotating with me, but it’s not facing me… Is there a way to determine what part of the mesh faces you? Any way I turn it in the blueprint, it still faces away

If I understood you correctly, by following you mean you want your static mesh to look at your player while your player moves. If that is so, then here’s a couple of things that you’re doing wrong:

First, you shouldn’t implement this in Level Blueprint. Create a separate Actor blueprint for your object, add your Static Mesh to it and implement this logic in that Actor’s blueprints.

Second, you must use the Tick event to update your actor’s rotation. This is a continuous event that needs to be updated as your player moves. The event overlap will fire only once, so your actor’s rotation will not be updated with the player’s movement.

Lastly, as a general rule, you don’t need to check and branch if you’re already using a Cast. Cast itself does something similar to that equality and branch node you have there. So you don’t need that redundant check.

Sorry, I wasn’t paying attention that this is implemented in the Actor’s blueprint. Since we want to know the angle from that Actor to your player, you need to swap the from and to pins in GetUnitDirectionVector. With the current opposite setup, your actor will always face the opposite direction of your player (I’ve updated my original answer with a new picture). Also, instead of taking just the yaw, take the whole rotation to completely face the player.

The next thing you want to check is that your mesh is facing forward along the ‘X’ axis in your blueprint coordinate system or you would have to manually add this rotation difference to it.