Moving Platforms in GMS ? [Solved]

Dirusym

Member
I really need help with my project.

Hopefully some of you can help me. I need moving Platforms in my game, but always get bugs and my Player stucks in it.

Step Event obj_Player:

GML:
/// Movement
//Gamepad!

if(t==0){ //Nur für die Tür Ani damit der Player an der Stelle bleibt !

if(gamepad_is_connected(0)){
    if(gamepad_axis_value(0,gp_axislh) < -0.5 || gamepad_axis_value(0,gp_axislh) > 0.5){
        hspd = (gamepad_axis_value(0,gp_axislh))*spd;
    }else {
        hspd = 0; // Weil standart wert nicht bei 0 sondern bei 0.02 ist !
    }
} else {
    var hspd = (keyboard_check(vk_right) - keyboard_check(vk_left))*spd; //Falls kein GAMEPAD dann KEYBOARD !
}

var jkey = keyboard_check(vk_up); // Für den Jump !
var keyh = keyboard_check_released(vk_up); // Smaller Jump !
var keyb2 = gamepad_button_check_released(0,gp_face1); //Für kleinere Sprünge mit Gamepad !

///Animation run!
if(keyboard_check(vk_right) || gamepad_axis_value(0,gp_axislh) > 0.5){
    if(run == 0){
        if(obj_game_controller.world == 0){
            sprite_index = spr_Player_White_Right;
        } else if(obj_game_controller.world == 1) {
            sprite_index = spr_Player_Black_Right;
        }
    } else {
        if(obj_game_controller.world == 0){
            sprite_index = spr_Run_White_Right;
            if(!instance_exists(obj_Run_An2)){ //Rauch Ani
                if (place_meeting(x, y+1, obj_solid)){
                    alarm[1] = 1;
                }
            }
        } else if(obj_game_controller.world == 1) {
            sprite_index = spr_Run_Black_Right;
            if(!instance_exists(obj_Run_An4)){ //Rauch Ani
                if (place_meeting(x, y+1, obj_solid)){
                    alarm[1] = 1;
                }
            }
        }
    }
} else if(keyboard_check(vk_left) || gamepad_axis_value(0,gp_axislh) < -0.5){
    if(run == 0){
        if(obj_game_controller.world == 0){
            sprite_index = spr_Player_White_Left;
        } else if(obj_game_controller.world == 1) {
            sprite_index = spr_Player_Black_Left;
        }
    } else {
        if(obj_game_controller.world == 0){
            sprite_index = spr_Run_White_Left;
            if(!instance_exists(obj_Run_An)){ //Rauch Ani
                if (place_meeting(x, y+1, obj_solid)){
                    alarm[1] = 1;
                }
            }
        } else if(obj_game_controller.world == 1) {
            sprite_index = spr_Run_Black_Left;
            if(!instance_exists(obj_Run_An3)){ //Rauch Ani
                if (place_meeting(x, y+1, obj_solid)){
                    alarm[1] = 1;
                }
            }
        }
    }
} else {
    if(obj_game_controller.world == 0){
        sprite_index = spr_Player_White;
    } else if(obj_game_controller.world == 1) {
        sprite_index = spr_Player_Black;
    }
}

//Run Keyboard !
if(run == 1){
    hspd = hspd*1.5;
}

// Check for the ground and Jump !
if (place_meeting(x, y+1, obj_solid))
{
    vspd = 0;
    
    if (jkey || gamepad_button_check(0,gp_face1))
    {
        if(!place_meeting(x,y-1,obj_solid)){ // Somit kann man nicht die ganze zeit hüpfen in Wänden !
            audio_play_sound(s_Jump, 1, false);
            vspd = -jspd;
            draw_yscale = 1.5;
            draw_xscale = .75;
        }
    }
}
else
{
    // Gravity
    if (vspd < 10)
    {
        vspd += grav;
    }
}

if(vspd < 0 && keyh){ //Kleinere Sprünge !!
    vspd = max(vspd,0);
}

if(vspd < 0 && keyb2){ //Kleinere Sprünge mit Gamepad !!
    vspd = max(vspd,0);
}


// Horizontal collisions // Keyboard
if (place_meeting(x+hspd, y, obj_solid))
{
    while (!place_meeting(x+sign(hspd), y, obj_solid))
    {
        x+= sign(hspd);
    }
    hspd = 0;
}

// Move horizontally // Keyboard
x += hspd;



// Vertical collisions
if (place_meeting(x, y+vspd, obj_solid))
{
    while (!place_meeting(x, y+sign(vspd), obj_solid))
    {
        y+= sign(vspd);
    }
    vspd = 0;
}

// Move vertically
y += vspd;

// Scale on landing
if (place_meeting(x, y+1, obj_solid) && !place_meeting(x,yprevious+1, obj_solid)){
        draw_yscale = .75;
        draw_xscale = 1.25;
}
Please help me :(
 
Top