Challenge: Implement Wall-Jumping.

Now that we have our elevator, we want to move on to our next section, which requires wall jumping. There are two things we want to do to set up; first we want to modify our player code to remove our ability to double jump:

and add in the following method to our player script:

Challenge: Fix the elevator jitter.

Currently, when we go up on our elevator, the movement up is not smooth. To fix this, we will first add a box collider (as a trigger) to our elevator, and drag the collider to encompass the player’s landing area:

Then we will add the code to use this collider in our elevator script:

Challenge: Implement our elevator movement upwards.

Currently, when we call the elevator, it moves from it’s top location to it’s bottom location. Now, we want it to move back up. We will start to implement this by first changing the box collider for our elevator panel to include the elevator:

The first thing we will do is modify our elevator panel script:

Challenge: Implement our elevator movement downwards.

Now that our elevator panel is set up, we want to create logic that governs moving the elevator down. Fundamentally, this is going to look like our platform movement script, using the movetowards function. First, we create an elevator script, attach it to our elevator, and modify our elevator panel script so:

Now, when our elevator panel script starts, it will find the elevator component. When the player calls the elevator, the callElevator method will run. This method will be accessed in our elevator script, which we will modify like so:

Challenge: Make our elevator require coins to operate.

Currently, our elevator light changes color to green when we get near it and press “E”. Before we update our script to actually move the elevator, we want to expand our requirements to include a coin limit. To start, we modify our elevator panel script to include a private int to cover our required coins (8, in this case), then modify our player script to include:

This will provide an int matching the number of coins that the player has. We can then utilize this number by modifying our elevator panel script:

Challenge: Initialize an Elevator in our game.

We have updated our game to include a few platforming elements:

One of these elements is an elevator. In order to utilize it, we want to to have several elements working at once. To break it down, we want our elevator to:

  • Move up and down
  • Only move up and down when we are near it
  • Only move up and down when we press “E”
  • Only move up and down when we have enough coins

To do this, we create a script that modifies our elevator:

Challenge: Add a coin collection and display mechanic.

Currently, we can jump and move around, but have nothing to collect. To rectify this, we are going to add in a coin collection system. First, we add two scripts to our game; one for a UI manager and one for a…

Alec Oney

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