First off, your code won't work if there are multiple moving platform actors with differing speeds. You should use this instead.
player -> Collision with top of move_ground (repeat) -> Script Editor
- Code: Select all
xvelocity = collide.xvelocity;
This code makes sure the event actor and the actor it is colliding with are the ones being handled. It might not make much of a difference in your game right now, but you should strive to be clone specific any time.
Now that delay is caused by the ordering of events, where the collision event is being triggered before the step that causes the platform to change direction. Assuming the platform isn't moving fast enough to move past the player (stopping collision), you can just do the following.
player -> Collision with top of move_ground (repeat) -> Script Editor
- Code: Select all
if(xvelocity==-collide.xvelocity)
{
x += collide.xvelocity*2;
}
xvelocity = collide.xvelocity;
All that if statement does is compensate for the single frame distance gap caused by the two actors going opposite directions.