How do I make a controllable camera that can orbit an AI?

I’m struggling on this part of my project and could use some help.

I have a level where I want the game camera to start zoomed out and then move to an AI character before it starts trying to solve a maze. I know that I can take the Player Controller and Set View Target with Blend for the sweeping shot at the beginning, but the part I’m struggling with is letting the player control a camera that will be locked to the AI character as it moves.

Are there any tricks that I can use to get this affect? If possible, I want to take this one step further and have the player cycle through multiple AI characters each time a button is pressed, but that can be figured out after I get it to work with one.

You can just create a pawn that will be the camera, then just attach that pawn to your ai.

Pawn components:

Scene - Spring arm - Camera.

Attach that pawn to the actor you want to orbit around.

To rotate camera check out some “Third person camera” tutorials.

To switch AIs just attach that CameraPawn to another AI

Have you tried rotating spring arm component on input action event?

How do I attach a pawn to the character? Would that be with the attach component to actor node? I tried that before but the camera went inside the actor even though I had a spring arm with a length of 300.

I don’t know how to do that properly.
I tried making a game controller bp to try and control a spring arm in the character’s bp, but I couldn’t figure out how to actually rotate it with the mouse

Use a mouse X event, use that to rotate the spring arm

To attach use AttachActorToActor.

You attach the whole CameraPawn to the AI, not just the camera.

To rotate the camera check “usePawnControllerRotation” inside the SpringArm.

to add actual input, your pawn has to POSSESS player controller (GetPlayerController → Possess)

Check out https://youtu.be/CYiHNbAIp4s?si=XVvEOYMts_ILOUxm to add inputs

I tried that before but couldn’t get it working. It’s possible that I had issues with other parts of the program, but when I tried it, I tried taking the X and Y mouse inputs to add relative rotation to the camera spring arm but nothing changed.

Can you send an example of how to do that properly?

I’ll try this once I get back to my computer, thanks!

When it comes to my idea for the future of switching between multiple characters, my thought is to have the game level send the camera pawn an array of all the AI characters and have a button input that will change which index in the array is selected, then switching to that character. Do you think that would work?

A mix of both RoflMast3r and Playwithmewerder’s suggestions created the answer. Rofl’s example of the rotation input was exactly what I needed to control the camera and Play’s instruction to attach the pawn has been a huge help to get the attaching style I need. I have been running into problems with the spring arm being stuck in the character’s body due to collisions, but I should be able to research that myself, or keep collisions off.

Just make sure that in spring arms collision, is set to ignore whatever channel this character is in

Get All Actors of class ( your ai actors) → select any item of the array (blueprint Get a copy node) → Attach to that AI