Moving Platforms in Unity3D

This is a short example of moving platforms in Unity3D.

Based on this tweet, I spent … 30 minutes? Maybe? putting it together.

This writeup took longer.

The approach uses two behaviour classes to achive the classical effect of moving platforms that follow some path.

  1. mark some empty GameObject as Waypoint instances
  2. give each Waypoint a next field
  3. attach a Mover instance to your platform(s)
    • drag the platform towards the next Waypoint at a fixed rate
    • when you’ve reached the Waypoint, continue with its next one

My example;

  • uses the concept of fuel to avoid losing movement when fast moving platforms don’t have far to travel
  • provides some Gizmo logic to make looking at it easier

Normal Unity3D Rigidbody instaces will impact with normal cubes - so if your platforms have a collider you’re all set. If you need-need Rigidbody platforms; you can make them Kinematic to avoid weirdness.

The platform will stop when it reaches the “last” Waypoint so you could modify the Mover to move backwards, or, just have the last platform point to the first platform and create a loop.

comments powered by Disqus
Peter LaValle avatar
Peter LaValle
Any links probably include affiliate ids for that sweet sweet kickback - and some programs require that I tell you. The contents of this blog are likely unrelated - as they include games, paints, and build tools.