2.5D Platform: Calling for an Elevator

I can now call for the elevator but it’s missing the elevator music :(

The idea is to have the player collect a number of coins to enable the ability to use the elevator panel and call the elevator by pressing the ‘E’ key.

I have an elevator game object all set up with an elevator panel. All I’ll need is two scripts. One for the Elevator, and the other for the Elevator Panel.

I created the scripts and attached them to their specified game object.

Elevator Panel Script

I want to detect for collision, and if it's the player, then I can press the ‘E’ key to call the elevator and turn on the light by changing the color of the material to a different color.

Elevator Script

When I press the ‘E’ key, I want to call the elevator so that it can go down from its current position to its target position. I used a bool for the Call Elevator function that will be called within in the Elevator Panel script. When I hit the ‘E’ key, the function will be called from there. I also want to take into account that there is a required number of coins I must collect for the elevator panel to work.

if (Input.GetKeyDown(KeyCode.E) && _canSwitch && player.GetCoins()               >= _requiredCoins)
_meshRend.material.color = _activeLight;

If the bool is true, then we are going down.

transform.position = Vector3.MoveTowards(transform.position, _target.position, _speed * Time.fixedDeltaTime);

If false, then we are going up.

transform.position = Vector3.MoveTowards(transform.position, _origin.position, _speed * Time.fixedDeltaTime);

I have two Transform positions that determine the points in space where I want the elevator to travel from A to B. And from B to A.

I also set the bool to false when the player exits the trigger.

private void OnTriggerExit(Collider other)
if (other.CompareTag(“Player”))
_canSwitch = false;


I now have a simple elevator that can be called to bring me up!

I want to mention that from now on, these dev logs will be more like personal entries where I write about areas I need help with. So it won’t be a complete guide, but more about thoughts that will help me remember. So I am sorry if a lot of it doesn't make any sense!

I also have my projects on GitHub.

You can access all of my scripts there!





Hello everyone, My name is Gabriel Perez, I am a Unity Developer and a creator who is always learning and experimenting.

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

Recommended from Medium

We’re Often Told To Add Things To Our Lives. Now It’s Time To Declutter Your Mind.

Announcing Lando Integration for Lagoon

Singleton: Audio Manager

DevOps VS. Site Reliability Engineering


Your Personal Brand: Week 1

What is Docker Compose and How to use it- PART-2

How to Install the Universal Render Pipeline

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
Gabriel Perez

Gabriel Perez

Hello everyone, My name is Gabriel Perez, I am a Unity Developer and a creator who is always learning and experimenting.

More from Medium

P1: Creating a Gritty Office Den

Introduction To Variables in C# For Unity

My journey becoming a Unity game developer: Make a game look beautiful-Creating support struts for…

Quick tip — Upgrading your Unity project to High Definition Render Pipeline (HDRP)