Legacy GM How to get consistent speed on moving platform

MaxLos

Member
Hihi,

Pretty much what the title says. When my player moves in the opposite direction a moving platform is, they reach the end of the platform way faster than when they are moving in the same direction of the platform. Just wondering what I should do to make the player move the same speed as they do in the direction the platform is moving, in the opposite direction. Thanks!

Code:
//Horizontal Platforms
if place_meeting(x,y+1,par_horizontal_platform) //If there's a moving platform beneath us
{
    var platform = instance_place(x,y+1,par_horizontal_platform) //Store id of that platform

        with platform
        {
            if !place_meeting(x+hsp,y,par_solid)
            {
                if (other.hsp = 0) or (other.hsp > 0 and hsp > 0) or (other.hsp < 0 and hsp < 0)//Check if player isn't moving at all or moving the same direction the platform is
                {
                    other.hsp_carry = hsp; //Add the platform's momentum to the player
                }
            }
        }
}

20200409_182519.gif
20200409_182837.gif
 

YoSniper

Member
Maybe rather than add speeds, just increase or decrease the player's x by the speed of the platform when the player is riding it?

Code:
if place_meeting(x, y+1, par_horizontal_platform) {
    var platform = instance_place(x, y+1, par_horizontal_platform);
    x += platform.hsp;
}
Should also make things simpler.
 

MaxLos

Member
Maybe rather than add speeds, just increase or decrease the player's x by the speed of the platform when the player is riding it?

Code:
if place_meeting(x, y+1, par_horizontal_platform) {
    var platform = instance_place(x, y+1, par_horizontal_platform);
    x += platform.hsp;
}
Should also make things simpler.
Well, I'm adding to the player's hsp since im using the standard collision system using place_meeting and hsp. I tried your code but it just does the same thing mine does but allows the player to move through walls and makes my movement problem even worse when I move in the opposite direction on the platform since it changes my x-coordinates directly
 
Top