The logic to do moving platforms would ideally be:
1. Move player
2. Find the platform the player is on, if any.
3. Move the platform, and move the player by the same amount if they were on it.
But because of when the behaviors run it can end up being:
1. Move player
2. Move platform
Or
1. Move platform
2. Move player
Depending on their order in the engine. It’s not something you can control. That’s what can cause them to not be synced.
The platform behavior does have logic to move with the platform it’s on, but it depends on which is moved first I suppose.
You probably don’t want to create a platform movement entirely with events but that would give the most fine control of stuff. On the other hand, it can be tricky sometimes to move stuff with events or other behaviors in a way to keep other behaviors happy.
In this case you probably can get away with it. So instead of using a motion behavior on the platform you’ll want to move it with events so we can do that ideal method listed above.
Here’s some simplish events to do that:
Global number onPlat =0
Global number dx=0
Player: is overlapping platform at offset (0,1)
—- set onPlat to 1
Else
—- set onPlat to 0
Start of layout
—- platform set speed to 200
Platform.x >400
— platform: set speed to -200
Platform x < 100
—- platform: set speed to 200
Every tick
—- set dx to platform.speed*dt
—- platform: set x to self.x +dx
If onPlat = 1
—- player: set x to self.x+dx
Now that assumes just one platform that just moves to the left and right from 100 to 400.
Multiple platforms could be done by saving the uid of the plat the player is on and only move the player by the amount that play moves.
Also you can make the platform motion as complex as you like. Just move the player by the same amount.