2.5D Platformer setup: Movement and Collectibles

Brennen Witzens
3 min readDec 20, 2021

--

The start of the platformer

So on to making 2.5D platformer, using primitives I set up a layout for the beginning of the level. Varied but simple enough to work at this stage.

Left: Variable region of the script. Right: Movement Method of the player controller script

After having the level layout the way I wanted, I started to work on the player controller. Using a Character Controller component as the base movement system. Outside of using the Character Controller to move, all physics and mechanics of how I want the character to move and interact in the world will be done in script by me. In the above pictures, I started out with grabbing the character controller object, and set up some different variables for what was needed to move. Similar to how the Space Shooter movement system was set up, using the horizontal axis to move left and right. Setting up the direction using a Vector 3, and the X position of the vector is the input value from the player, aka the movement. With that it was figuring out the velocity which is speed with a direction.

Movement, double jump and collection

From there it was setting up gravity and the double jump. Gravity is a downward force! (I know shocking). Thought it is always present, we only need it to be present when the character isn’t touching the ground. So if the character isn’t grounded aka having jumped or fallen, it effects the Y value of the velocity vector. With a quick bool check to see if we’re in the air, we can allow for another press of the Jump button (in this case C), and give them a double jump.

Last but not least is the collection of the collectibles. Making sure they’re a trigger, the player walks into them.

If it is the player that walks into them then send an event to the player (in this case), to increment the coin variable the player has. Then set the object to inactive, though destroying is also possible. The player then has a method that updates the UI text on screen, showing the collection was successful.

With this, it’s the start of a new series. The 2.5D platformer, and the first section is out of the way. On to the next.

--

--