Creating a Lift

Niraj Karki
2 min readJul 29, 2021

--

2.5D Game Development

Objective: create a lift that waits for few seconds in either end before moving again.

To start of select a elevator floor and add a script named Lift as its component. Then create two game objects and give them a position of either end of the elevator so that we can give our elevator a position to move towards.

Now create a variable to reference to the two gameobjects created. Then create another float variable which determines the speed at which the elevator will move, then a vector3 variable which stores the next destination and finally two bool variables which is used to set a condition to move the lift set the next destination.

Now create a coroutine that determines the destination of the lift i.e. if lift is on top then the destination will be base while if in base then the destination will be top.

Now set the condition to change the bool value which then will change the destination in the coroutine. Then move the lift to either position by changing the value in y axis. We are using this method instead of move towards is because there are colliders which makes the elevator to move in un-elevator like pattern.

And this is the result.

--

--

No responses yet