Making a Smooth Following Camera

• 94 favourites

Stats

17,255 visits, 25,675 views

Translations

• Portugese (Brazillian)

Tools

Ok, this tutorial is about making a camera follow the player smoothly.

Exemple: http://militia.com.br/example1

First

You need to create your player, I'll not explain it here, you can find in Beginner's Guide how to starting using Construct 2.

Creating the Camera

Ok, after you create your player, create a blank sprite, rename it to "camera", this will be your camera.

It preferable to put the camera close to your character, or when you start the game the camera will move to the character if is too far.

But you can use this position to make a entrance for the game, for example you can put your camera in the sky, and when the game start the camera will move to your player position.

Event Sheet

Create an event Add Event>System>Every Tick and create an action Camera>Set Position

X: lerp(Self.X, Player.X, 0.03)

Y: lerp(Self.Y, Player.Y-150, 0.03)

Explanation

The magic here is the expression "lerp", when you use it, you need to put 3 values, the first one is the initial position, the second one is the final position, and the third one is the time will take to run between initial and final position.

So Self.X is the current position from the camera, and Player.X is the current position from the player.

The 0.03 can be any number, if you want your camera smoother you can decrease the number or vice versa.

For the Player.Y I inserted a "-150" because your character will be always in the middle of the screen, and in this case was better for the player to be in the bottom of the screen.

• Order by