How to follow the player (or an object) with the camera?
Following a character (also called an object) with a camera is a key aspect of video game design that creates an immersive experience for players. This article includes instructions for implementing this functionality either with a simple extension like Smooth Camera or a set of actions on the Event Sheet.
Tip
Learn more about layers and cameras and how to keep UI objects on screen.
Follow an object smoothly
Adding the Smooth Camera behavior to the character. The Smooth Camera's parameters such as "catch up" and "speed" can be modified to personalize the smoothness of the camera movement.
Tip
Learn how to install new extensions by following a step-by-step guide.
Keep an object at the exact center of the screen
To configure the camera to center on an object, go to the event sheet and add an Action (no need to set a Condition) called "Center the camera on an object".
Select the character that will be followed by the camera and check that the layer of the character is selected.
The Action should look like this:
Tip
To get closer to the character with the camera (zoom-in), use the action Move camera closer.
Follow an object with several cameras (layers)
Games can contain a lot of objects. Using several layers is a way to keep a project organized, but also to manage camera movements. All layers (except for UI layers) should likely be moved the same way when a character is followed. Read more on how cameras and layers work.
To follow an object with different cameras (layers), install the Copy camera settings extension. It allows to copy the camera's position to any other camera, including the camera that follows the player.
Make a custom camera following (advanced)
To add camera inertia and a smoother transition watch this video tutorial to learn how to use the Camera Center positions on the X and Y axis, along with lerp
expressions and formulas.