1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 platform for enemies and player

Discussion in 'Programming' started by jonjons, Apr 25, 2019.

  1. jonjons

    jonjons Member

    Joined:
    May 10, 2017
    Posts:
    298
    hello
    i wanted the player and enemies to be able to go trough platforms without messing each other up
    ive made a way of changing the walkable object based on what ground they are on.

    the problem here is that the if and the else leave a gap of 1 step, making the objects sometimes locked inside a wall
    Code:
    if ( place_meeting(x, y-1, obj_Platform) < place_meeting(x, y+22, obj_Platform ) && platGo == 0 ) // 22
    {
        wallWalk = instance_place(x, bbox_bottom+5, obj_Platform);
    }
    else
    {
        wallWalk = obj_wall;
    }
    in this case if the player/enemie is on top of a passable platform and jumps up if there is a wall on top they will get stuck inside a wall

    ive also tried to make the code in only one if to close the gap but gm cant retrieve 2 objects at once
    var wallCHK = instance_place(x, y+10, ( obj_wall || obj_Platform );
    if ( wallCHK != noone )
    {
    wallWalk = wallCHK;
    }
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,143
    if vspd>0
    with instance_place(x,y+vspd obj_platform)
    if !place_meeting(x,y,other) {

    other.vspd = 0;
    other.y += bbox_top - other.bbox_bottom - 1;

    }

    (Can't remember if the -1 was necessary)
     
  3. jonjons

    jonjons Member

    Joined:
    May 10, 2017
    Posts:
    298
    it seems to work, but a lot of problems have poped up
    it seems to be realted with the isOnGround collision

    iam using -1 to check if the player is on ground
    Code:
    if ( place_meeting ( x, y+1, wallWalk) && vsp >= 0 )
    {
        grounded = 0;  //----//--plr-stand------------
        vsp = 0;
    }
    else
    {
        grounded = 1;  //----//--plr-onAir----------------
    }
    for the code to work i have to use if ( place_meeting ( x, y+1, wallWalk) || vsp == 0 )
    and the player gets stuck inside a wall if jumping with a wall on top
    How is the code checking if the player is on ground or on air ?
     
    Last edited: Apr 25, 2019

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice