Moving Platform

Checked with version: 2017.3

-

Difficulty: Beginner

A Prefab located in the Project window in Prefabs > Interactables

To create a Moving Platform in your Scene, drag a MovingPlatform Prefab from the Project View into the Scene View.

It includes a Moving Platform Script, Box Collider 2D, Rigidbody 2D, Platform Effector 2D and a Platform Catcher Script.

The Platform Catcher Script allows GameObjects on top of the platform to move freely. You should not need to change this.

In the Scene View, the GameObject has a red dotted line with a Transform Tool on the end. This indicates the movement path of the platform and its destination. Drag the Transform Tool in any direction to change the path and destination.

  • Platform Catcher: This automatically finds the Platform Catcher Script on the Platform. You should not need to change this.

  • Preview Position: Allows you to scrub through and preview the platform's path in the Scene View.

  • Start Moving: When enabled, the platform starts moving as soon as a level is loaded. If unticked, it needs to be triggered by an event.

    • When becoming visible: This option only appears if the platform is set to Start Moving. If this is enabled, the platform starts moving only when it becomes visible on screen, not when the level is loaded.
  • Looping: Defines how the platform reacts once it reaches the end of its path.

    • BACK_FORTH: platform moves back and forth between a start and end point.

    • LOOP: Once the platform reaches the last point of its path, it moves towards the start point in a straight line to restart the cycle, making a loop.

    • ONCE: The platform stops when it reaches the final point.

  • Speed: Default Setting: 2 The speed at which the platform moves (in units per second).

  • Add Node: This button adds another Node, or destination point to your platform’s path. A platform moves from Node to Node.

    • Node 0: The platform position. Cannot be deleted. There is no position as this cannot be altered.

      • Wait Time: The amount of time the platform waits to move on to the next Node.
    • Node 1: The first path and destination, this is always included by default.

      • Position: The position of the Node (local space).

      • Delete: The button to delete a Node.

      • Wait Time: The amount of time the platform waits to move on to the next node.

A platform with two Nodes looks like this in the Scene View.

Related tutorials