Setting Up the Camera System Component
To add the GCMS_CameraSystemComponent to your character, ensure that your character has both a spring arm and a camera component attached.
Initializing the Camera System Component
Next, call the following function to initialize the camera system component when beginplay:
You will also need to specify a default camera mode class in the component's details panel.
Switching Camera Modes
Switching camera modes is as simple as calling this one API:
Creating Camera Mode
To create a new camera mode, simply create a blueprint that inherits from GCMS_CameraMode. It is recommended to prefix your camera modes with CM_.
Default Parameters
A newly created camera mode comes with the following default parameters:
The most notable part is the Blending section, where you can adjust the blending method and duration for the camera mode.
The View variable is a blueprint read/write structure. The main purpose of camera mode is to update this View structure while active and serve as the "output" for that camera mode.
Writing Camera Mode Logic
A camera mode provides several functions for you to override:
Pivot Location and Rotation
The PivotLocation and PivotRotation functions already have default implementations with comments explaining their purpose. Generally, you do not need to override these two functions unless you want to customize the pivot points for the camera.
Lifecycle Functions
You can override OnActivation and OnDeactivation to perform initialization and cleanup tasks, similar to an Actor's BeginPlay and EndPlay.
Updating the Camera Mode View
The core part of a camera mode is updating the camera mode View in the OnUpdateView function based on your actual game logic.
You can access information beyond the camera mode through AssociatedCamera, AssociatedSprintArm, and TargetActor, allowing you to customize your logic based on this information. OnUpdateView will be executed every frame while the camera mode is active.
Reusable Camera Modes
GCMS provides an extensible code structure for creating and deriving camera modes. The current GenericGame companion project also contains inspectable Blueprint camera examples. These belong to project Content rather than the code plugin; some include fuller default parameters and can serve as starting points for project adaptation.
For example, here is a camera mode suitable for third-person games:
This mode offers additional default parameters, allowing you to drive the camera mode View's parameters using curve values or fixed values. You can create more camera modes by using it as a parent class and adjusting the curves, blending types, blending durations, and other parameters to achieve different camera control effects.
Use Case
In this example, I have three different camera modes. The default mode is CM_ThirdPerson. If I am aiming, it switches to CM_ThirdPerson_ADS; target lock can switch to a project-defined CM_ThirdPerson_Targeting mode.
Here’s how these camera modes appear in the actual game:
Camera assets in the current companion project
The Unreal Asset Registry confirmed two groups of examples in the current GenericGame project: CameraCore contains CM_GCS_TopDown, BP_GCS_CameraPawn, and C_GCS_CameraZoom; CameraExtras contains CM_ThirdPerson, CM_ThirdPerson_ADS, CM_ThirdPerson_CertainAbility, and CM_ThirdPerson_ViewDirection. The current project inventory did not find a CM_ThirdPerson_Targeting asset, so treat the target-lock mode above as a project-defined example. See the Companion Project Content and Example Assets guide for full paths.
Extendability
The camera system component is not limited to character-based Actors; you can apply it to any Actor and add various camera modes. You can switch between these modes based on game logic. For instance, in a resource management game, you might control a camera actor and manage your camp in Topdown camera mode during certain scenarios.