There are many different ways to work with a camera in games, and it can vary a lot depending on the type of game that you’re making. In Unreal Engine, cameras are typically composed of an actor with a spring-arm component, and a camera component, which renders the view. For basic camera setup, check out Using Cameras in Unreal Engine.
In this document, the developers will cover how they decided to implement the camera for Parrot specifically, and any settings of note worth pointing out.
Parrot Camera Subsystem
To start, each map that may have camera settings specific to the world was identified.
The developers created UParrotCameraSubsystem which shares the lifetime of the world and initializes the camera with these settings on BeginPlay. The map specific settings are stored on AParrotWorldSettings, which is useful for storing any per map data. For the camera, this is the desired camera class, the movement mode, and the upper/lower boundary on Z where we no longer want the camera to follow the player. The class itself is optional and not providing one is a valid path. This is done on the main menu.
For the reasoning on choosing to use a subsystem, refer to the Subsystems in Parrot documentation.
The world settings can be found in the World Settings panel in the editor.
Parrot Camera
AParrotCamera is where the bulk of the logic happens. When the camera is initialized by the subsystem, it is given: the player to follow, the movement mode, and the boundaries from the world settings.
The camera has three possible movement modes: None, Fixed, and Follow.
None is exactly as described. The camera will do nothing.
The Fixed movement mode is simple. When the player enters a bound volume, a fixed location is given to the camera by the camera subsystem and it will interpolate to it. The player is then free to move about until the movement mode is updated.
The Follow movement mode is more complex and best understood by looking at Content/Blueprints/BP_PlatformerCamera for a visual reference. AParrotCamera has a movement-trigger box and a blocking mesh as default subobjects. This means every instance of AParrotCamera has them automatically added in its hierarchy. Both are aligned with the camera frustum, spring arm, and perspective for the desired effect. Both of these components are attached to the camera actor and follow it within the world.
The blocking mesh prevents the player from moving backwards by colliding with the player in the world.
When the player overlaps the movement-trigger box, the camera will attempt to interpolate to the player’s X value at a set speed. The speed is also multiplied by the player’s distance past the left-most extent of the trigger volume. This way, the farther the player is into the volume, the faster the camera should move to catch up.
The result is that the player is able to roam freely on the left side of the screen up to the blocking mesh, yet the camera will move with the player when they pass the threshold. This provides a nice effect as the player moves through the world on the X-axis.
Another area of note on the Follow movement mode is that the player’s last known location is tracked. If the player’s Z surpasses the world bounds, or the player character is destroyed, we interpolate the camera to the player’s last known location. This prevents any jarring camera behavior based on the player’s movement/state.
Lastly, the Camera Component itself on BP_PlatformerCamera has a few settings worth pointing out. The Projection Mode is Perspective with a 90 degree FOV and an aspect ratio of 1.77 which is standard HD. Under Camera Options, we constrain the aspect ratio so that the camera always looks correct regardless of the application's running resolution.