How do I automatically rotate the camera when the players walks or turns?

I’m trying to get a camera system that will turn/change angles based on the player’s position.
(II hoping for a N64-style camera, but I’ll take any automatic camera system at this point.)

Thank you for reading!

You have multiple options, but the easiest one is probably using actors with volumes and independent cameras, when you enter a volume you start seeing through its associated camera with the SetViewTargetWithBlend function, it also allows you to blend smoothly between the two cameras.

When you no longer need to use those cameras you can “re-possess” your player’s camera.


Steps to do this easily:

  1. [OPTIONAL] In the Player Controller store a reference of the default camera component (if you want to be able to easily repossess it later)
  2. Create a volume actor with an UCameraComponent and an UShapeComponent (Box, Sphere, Capsule)
  3. Use the OnBeginOverlap function of the shape component, check if the overlapped actor is the player and from it get the player controller
  4. Call SetViewTargetWithBlend on the player controller passing the volume-associated camera
  5. [OPTIONAL] Create a volume that resets the player camera (Get playercontroller as before, cast it to your PC and get the DefaultCameraComponent variable you’ve created in point 1)

P.S. You might need to change what the inputs do based on the camera view, because if you turn 90° forward might become left or right, so you need to adjust them

P.P.S. You could create functions inside the PC and call them through an interface from the volumes instead of casting (it’s better but much longer to explain and has almost no impact on the performance)

1 Like