How to make a camera follow an AI character?

I had similar setup, here is what i did:

  • all player characters (squad game, wanted flexible system) were AI characters, with really simple AI: just go to location.
  • I moved those characters by finding walkable spots in some small radius like 200 units or so. (Then navigation volume and line trace to find walls etc).
  • then i added camera pawn (just camera, with camera logic like zoom, pan, pitch). Camera Pawn would read world location of controlled player character and snap to it (updating location and rotation on event tick)
  • some tweaks to camera pawn were required: using camera arm with small lag to soften and hide jittering (was minimal anyway, but just in case somebody could notice it)

I tried to swap AI controller for player controller when needed, but i think it was impossible or bugged during runtime, or maybe multiplayer was not working well with it. Also for tactical top down squad game (and for debugging) being able to detach camera was great.

So you can make something like that, just more advanced (3rd person and FPS like modes for camera). Add sockets around player character and snap to them, set camera arm length to 0 for FPS.

1 Like