Camera Components

The CameraComponent (which adds a camera perspective to view from) and SpringArmComponent (which extends its children at a fixed distance then retracts when a collision occurs), when used together, provide functionality for a 3rd person perspective that can dynamically adjust to your game world.

Camera Component

The CameraComponent adds a camera perspective as a sub-object to an Actor. The CameraComponent will provide information about the camera's properties if the ViewTarget is a CameraActor or an Actor that contains a CameraComponent and has its Find Camera Component When ViewTarget option set to true.

For example, you could use CameraComponents to switch between multiple cameras in your level during gameplay. By using Set View Target With Blend and a CameraActor, you can switch between each of your cameras and use the properties that you define within the CameraActor for each camera (including field of view, angle, Post Processing effects, etc.).

A related property that can be set for any Pawn is Take Camera Control When Possessed, which causesu the Pawn to become the ViewTarget automatically upon possession by a PlayerController. So, for example, if you had multiple Characters (which are a form of Pawn) that you wanted to switch between, and each of them had their own CameraComponent assigned to them, providing the camera perspective to view from, you could set Take Camera Control When Possessed to true for each of them and whenever you switch between them, the CameraComponent for that pawn would be used.

Spring Arm Component

The SpringArmComponent tries to maintain its children at a fixed distance from the parent, but will retract the children if there is a collision, and spring back when there is no collision. Typically, the SpringArmComponent is used as a "camera boom" to keep the follow camera for a player from colliding into the world (without the SpringArmComponent, the CameraComponent will remain at the fixed distance specified regardless of objects that could potentially get in the way of it and the object it is attached to), see Using a Spring Arm Component .

camera_springArm.png

Above, a CameraComponent (Camera) and SpringArmComponent (red line) are used to create a 3rd person perspective for a character.

You can adjust several camera related properties on the SpringArmComponent such as the TargetArmLength which is the natural length of the spring arm when there are no collisions, Probe Size or how big should the probe sphere be when checking for collisions, as well as things like CameraLag useful if you want the camera to lag slightly behind the object it is attached to.