Elevator Lift 2.0- Game Dev Series 93

Objective: create an elevator with 5 seconds pause on each stop.

We’ve created a moving platform before. This time we will make the elevator as a routine moving platform with specific pause time on each stop.

Packing the lift

To make a platform moving between 2 position, we need to create 2 empty objects to storage the position information. However, we should make sure the lift is on the right position.

As you can see, my lift has a different pivot point which makes it on a weird position in game scene. To fix this issue, we can simply create an object and make the lift as its child.

Once packed the lift, it would be easy to make it moves.

Moving between stops

Create a new script and create 2 gameobject variables to storage the position, then create 2 empty in scene as destination.

Then create a Transform variable as target position.

Now we can create the moving method of lift.

In this script, I use switch statement with a bool to control the moving direction of lift.
Play it and you should see your lift as a moving platform.

5 seconds on each stops

To make it stopping at each stops for 5 seconds, we need to create a coroutine and a bool as switch.

In this coroutine, we will switch the bool of moving direction after 5 seconds waits.

Then we can call this coroutine after the lift is reached one of stops.

Since the moving method is in Update(), we don’t want it to call coroutine every frame. That is why we need the bool that we just created.
Add the bool into if statement and also switch it again in coroutine.

All done! Play it and enjoy the result!

--

--

--

A passionate gamer whose goal is to work in video game development.

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

Recommended from Medium

Serverless Databases: Pros & Cons, Benefits, Examples on the Market

Serverless Databases: Pros & Cons, Benefits, Examples on the Market | TechMagic.co

My journey in GitHub Campus Experts: Part 1

SAP S/4 HANA Cloud — Future of Profitable Business

Capacitive Sensing with Piezo

Rotating in World Space- Game Dev Series 141

Maximum Subarray Product Performance: Divide and Conquer vs Kadane’s Algorithm

Yearn Governance Roundup #3

Talking about ‘not so’ Restful Routes

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
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

Magnetism in Unity Made Easy!

Day 103: Creating A Ledge Grab in Unity Part 1

Learning Unity — The Singleton Design Pattern

Adding a burst laser powerup