Moving Platforms in Unity

Ben Pielstick
1 min readMay 21, 2021

Getting stuff to move around in Unity is easy. For most things stuff transform.translate is all you need. When you want stuff to stick together though, things get a little more tricky, but thankfully only a little more. While not explicitly stated anywhere in the documentation that I could find, Unity will let you move two objects together as long as one is parented to the other. There are a couple of exceptions to this however, such as they both can’t have rigidbody components, and they both can’t have conflicting fixed update movement. As long as neither of these are the case though, all you have to do is set up and tear down a parent relationship between objects.

On enter set parent, on exit remove parent

You will of course need a rigidbody and a trigger collider on your parent object for this to work, but once you’ve sorted that out there aren’t any other extra steps. A player jumping on this platform with the basic character controller will stick to it as it moves, and will return to world space movement as soon as they jump off. You can then use these platforms anywhere, and move them any way you want without worrying about any more physics.

--

--

Ben Pielstick

Game developer with over 12 years of experience, mainly focused on MMOs.