Sticky platforms

sirhopsalot's sister here.

I was wondering how you make platforms that when they move you move with it.

Here is a script that may help.

untitled script pic (4)

untitled script pic (3)

Upon the player touching the platform, it creates an offset that is the difference between player's x position and the platform's x position, then until the player stops touching the platform (or some other condition), it sets the player's x position to the platform's x position plus the offset.

The 'some other condition' is a placeholder for something like.. maybe the player jumping or teleporting away.

EDIT: I just noticed I didn't account for the player possibly walking on it, but that would be easy.
When you're on the platform your walking/running keys should modify the offset instead of the x position. Hopefully, that won't be too hard to understand...

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.