AI camera that tracks player movement?

Hey guys, I’m trying to make a security camera that tracks a players movement when they enter the field of vision. I want the camera to track the player and after a certain period of time, I want it to spawn an enemy AI at a random location near the player.

I found this tutorial: Security Camera, Alarm, and Door | Unreal Engine Documentation and it’s help a little bit, but I still can’t figure out how to get the AI to spawn randomly while still being near the player. I also don’t know how to create the animation to track the player movement. I can create the simple turning animation, but it doesn’t follow the players location.

Hi.

This should let you spawn a class ranomly within a certain range of the player. You may want to keep the bounding box scale in Z down however, to prevent you AI appearing above ground and falling!

https://i.imgur.com/HDK1pqh.png

This will have your camera constantly point at the player:

https://i.imgur.com/ukh8KVc.png

Doing it this way will mean it’ll constantly move, no matter how fast your player character is moving.

Wow! Thank you for such a fast answer. It’s 5 a.m. here so I’m about to get some sleep, but as soon as I wake up I’ll try this out and let you know how it goes!

Everything works perfectly! Thank you so much.

Glad to hear. You may want to extend this by checking the angles provided by the FindLookAtRotation before setting it on the camera, to limit how far the camera can move - otherwise if you’re stood right below it, you may get undesirable results.

Alright I’ll check that out. Thank you again for the help!