GameDevHQ 2.5D Cert Requirements Part 6

Simon Leen
2 min readSep 7, 2021

--

Objective: Create a Moving Platform

We’ll start by setting up a platform base. We will put this inside an empty object called Moving Platform. Then create some empty object transforms and name them Waypoints. We have done something similar to this in the previous 2.5D Platformer section but this time we will use a List of transforms inside the script which will allow any number of waypoints to be set in the inspector.

Create the script called MovingPlatform. Set up the serialized private list of Tranforms, a serialized private int to identify which platform to move to and a private float for speed.

We don’t need the Start method and we can change the Update to FixedUpdate to fix the jittering when the Player is on the platform. Move the platform position towards the first waypoint at the set speed then run a conditional if to check if the platfrom position is at the target waypoint position then run a next conditional if to check if we are on the last waypoint. If so set the target waypoint to 0 or else add 1 to the integer value. We will use an OnTriggerEnter and OnTriggerExit using the Players tag which will make the Player a child object of the platform when on it and revert back to no parent when the Player comes off the platform.

The platform needs 2 colliders one to stop the Player falling through and one to act as a trigger which is set higher than the platform bounds.

The platform also needs a Rigidbody set to Kinematic and don’t use gravity.

--

--

No responses yet