Rusben Guzman

Moving camera with the player

Objective: Make the main camera move with the player.

We start developing the game but can only visualize the features in the scene windows. In order to see the player in the actual game window we have to make an adjust in the main camera.

The easiest way to make the camera follow the player is to set the camera as a child of the player. With this change the camera is going to follow the player movement and we can see it in the game window.

Give another jump to the player.

Objective: allow the player to jump twice before touching the floor again.

We have ready the player jump, but now we want to give the player the chance to jump again before touching the floor.

In the player script I created a new bool variable called _doubleJump, then in the update method when we check if the player is grounded, if it is true we set the value of the bool to true and if it is false we check for the space key and if the _doubleJumpp variable is true, in that case we add the jump height to the vector and set the value of _doubleJump to false to avoid to jump again.

Make the player be attracted to the floor.

Objective: add gravity to the game through script.

We have a player able to move but he is static in the Y axis and that is not the behavior we want. In this case we are going to add gravity through scripting.

In the player script I created a new variable for the gravity value. Then in the update method now I check if the player is grounded, if it is false so we are going to apply the gravity by subtracting the value of the gravity variable to the velocity vector in the Y axis.

Creating level structure

First I created some primitive shapes in the scene to represent the player with a capsule, the platforms with cubes and the coins with spheres.

Then I created a prefab folder in the project and added the platform and the coins.

Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.