2.5D Platformer setup: Movement and Collectibles

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.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

I’ve been using Zoho for the past months. Here’s how I managed to make it work for my team.

How to change the timezone of containers running in k8s

What I Learned (off) Work this Week: Don’t Forget Your Algos!

Using Python And Twitter API 2 to Get User Details

Look back on my activities in 2021

Software Engineering Immersive Journal?

Python len()

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Brennen Witzens

Brennen Witzens

More from Medium

Cinemachine — Under Attack

Animating Sprites In Unity

Building A Stealth Game — Creating Security Cameras

Fitting Unity in the Graphics Pipeline