Legacy GM How to code moving platform collision?

so i've been working on a platformer project in GMS 1.4.9999, and i've been trying to add moving platforms to it but they always have some issues...
so i decided to just scrap it and redo the moving platform collision code from scratch, but nothing i've tried has worked and i need some help
any ideas??

i want the player to be able to collide with the sides of moving walls too, and not just the tops of them, and also be able to wall jump off of moving walls on either side of the wall

like, the wall should be able to push you if it moves towards you
you should be able to go towards it and collide with it if it's moving away
and if a moving wall pushes you into another wall it should kill you, restarting the room

this is my movement code so far:
GML:
if keyboard_check_pressed(vk_left) or keyboard_check_pressed(vk_right){
    hspd = 0;
}

if map = false{
    if keyboard_check(vk_left){
        hspd -= 1;
    }if keyboard_check(vk_right){
        hspd += 1;
    }
}if !keyboard_check(vk_left) && !keyboard_check(vk_right){
    if hspd < 0{
        hspd += fric;
    }else if hspd > 0{
        hspd -= fric;
    }
}

if hspd > 6 hspd = 6;
if hspd < -6 hspd = -6;

if place_meeting(x,y+1,obj_wallparent){
    if map = false{
        if keyboard_check_pressed(vk_up) or keyboard_check_pressed(vk_space){
            vspd = -jspd;
        }
    }
 
    double = true;
}else if double = true && (keyboard_check_pressed(vk_up) or keyboard_check_pressed(vk_space)) && global.level >= 21 && map = false{
    vspd = -jspd;
    double = false;
}

if global.level >= 21 && map = false{
    if place_meeting(x+1,y,obj_wallparent){
        if !place_meeting(x,y+1,obj_wallparent){
            if keyboard_check_pressed(vk_left){
                vspd = -jspd;
                hspd = -6;
                double = true;
            }
        }
    }if place_meeting(x-1,y,obj_wallparent){
        if !place_meeting(x,y+1,obj_wallparent){
            if keyboard_check_pressed(vk_right){
                vspd = -jspd;
                hspd = 6;
                double = true;
            }
        }
    }
}

if !place_meeting(x+hspd,y,obj_wallparent){
    x += round(hspd);
}else if !place_meeting(x+sign(hspd),y,obj_wallparent){
    while !place_meeting(x+sign(hspd),y,obj_wallparent){
        x += sign(hspd);
    }
}


if place_meeting(x,y+sign(vspd),obj_wallparent){
    if vspd > 0 vspd = 0;
    else vspd = 4;
}else{
    if vspd < 20*grav vspd += grav;
}

if !place_meeting(x,y+vspd,obj_wallparent){
    y += vspd;
}else if vspd > 0{
    while !place_meeting(x,y+1,obj_wallparent){
        y += 1;
    }
}
moving wall is called obj_movingwall
it moves along a path, and it has a spd variable that defines how fast it moves along the path
 
Last edited:
Top