Legacy GM [Solved] Moving platforms wall collision



So I finally got around to learning how to make moving platforms using one of Shaun's old tutorials. It works great but it has one "problem" that bothers me: if the player is standing on a moving platform that moves into a wall it kinda pushes the player a bit in that direction. Not a big deal, but again, it bothers me lol

Moving Platform.gif

var hsp_final = hsp + hsp_carry;
hsp_carry = 0;

//Moving Horizontal Platforms
if place_meeting(x,y+1,obj_horizontal_platform)
    var platform = instance_place(x,y+1,obj_horizontal_platform)
    if (bbox_bottom + 1 = platform.bbox_top)
        hsp_carry = platform.hsp;

//Standard collision code here..
Any idea how I would fix it? Thanks!


You could try only applying the platforms hsp to hsp_carry if that platform has no collision in the direction it is moving, but ultimately End Step, or even Begin Step need to be utilised with moving platforms.
Last edited:


šŸ§ *penguin noises*
GMC Elder
An easy fix would be to make platforms move in Begin Step rather than Step, so they're guaranteed to be processed before the player (and not change direction mid-process). Basically moving platforms are standing still for all other objects' perspective during the step event. Thinking of it that way makes them a lot easier to deal with.

I'd go one step further, though: have platforms be responsible for moving anything they can push, too. Do a with loop for a platformPushable parent (or whatever) and if there's any in the platform's way (x+hsp,y+vsp) or on top of the platform (x,y-1), have them attempt to move in the same direction as the platform. (If there's an obstacle there, don't move, and/or kill the object if it's crushed between things that can crush it - this logic gets a lot messier to figure out)


I agree with @Yal on the approach, but just wanted to point out that although an undesired effect, its actually quite cool.

Joe Ellis

I agree with Yal's approach, rather than dealing with it in the player's code, do it in the platform. (in begin step) before moving the platform, first check if the player is just above it, if it is move the player also by it's hsp & vsp. Then in the player's step event, after it's been moved by the platform, it's normal movement & collision will still work as you'd want it to. ei. it can still run\accelerate etc. and it ends up moving relatively with the platform in a realistic way, or a way that looks right, and the carrying naturally gets broken when the player jumps or walks off the edge of it


Woo! Thanks everyone! Changed it from the Step Event to the Begin Step Event and that fixed it :D
Thanks for the advice about handling it in the platforms, I just thought it would be better performance wise to handle all the checks in one instance if possible