Making Elevators In A Unity Platformer

Today I’m building upon yesterdays “Moving Platforms” to make a callable elevator.

Press button, elevator comes, ride to the top!

Today’s Objective: Expand upon the existing automatically and continuously moving platforms to create an elevator which can be enabled and disabled.

The Design:

Following on from yesterday’s Medium, we already have an object which can move between any number of waypoints, and can be stopped via the “_movementEnabled” boolean. So to make it an elevator we simply need to make it able to be remotely activated, called, and deactivated.

For that purpose, I create a new object in the world to act as the remote elevator “button”:

The elevator panel, in this case, is a simple rectangle with a small sphere and a 3D TextMeshPro object as child objects. The sphere will change color on activation, and the text will show “Press E To Use” when the player is in range.

The trigger collider is larger than the panel, and activates the text popup and input checks when player is inside it.

The Code:

Now I create a new script called “WorldButton”. The idea with this component is not to force it to only be a elevator button, but instead design it to be modular and reusable.

For that reason, it uses UnityEvents rather than hard-coded commands. In this way, I can make it do anything upon activation:

First, the variables:

Then the functionality:

Input checks and function starts.
Toggle activation functionality.
Trigger zone entry and exit functionality.

Now by simply adding in whatever functions I want into the Inspector UnityEvents, I can make the button do anything for any cost:

--

--

--

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

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

Recommended from Medium

Logical Time and Lamport Clocks (Part 1)

Run Multi-container apps with Docker Compose

Making Service Workers easy!

Auto Rolling Restart K8 pods when change in ConfigMap through Stakater Reloader

DLithe 1st Week of BootCamp

Signals and the Deep Declarations Between macOS and Linux

The Java CPU usage observer effect

System CPU Usage graph

WordPress Starter Kit

WordPress Starter Kit — Plugin Series

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
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

More from Medium

Making Moving Platforms In A Unity Platformer

Moving Platforms in Unity

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

Loading Scenes In Unity