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.
- mark some empty GameObject as
Waypoint
instances - give each
Waypoint
anext
field - attach a
Mover
instance to your platform(s)
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.