1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GML [Solved] Fail in collision :(

Discussion in 'Programming' started by Loïc Mouton, Nov 10, 2019.

  1. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    9
    Hi GMC !

    I'm new in the Game maker Community and i've a problem with the collision of my player.

    On the platform, he has collision but he can pass trough wall :/

    upload_2019-11-10_17-12-47.png

    Here it's normal ...

    upload_2019-11-10_17-13-32.png

    But here it's not normal at all.

    I thinks the problem is from my code for vertical colission so there is it :

    Code:
    if (place_meeting(x, y + vspd, obj_Wall))
    {
        while (!place_meeting(x, y + sign(vspd), obj_Wall))
        {
            y = y + sign(vspd);
        }
        vspd = 0;
    }
    
    y = y + vspd;
    Thanks for your help !!!
     
  2. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,881
    The code you posted only checks BELOW you, do you have any collision checking to the left / right as well?
     
  3. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    9
    Oh you're right, there is my code for horizontal collision :
    Code:
    if (place_meeting(x + hspd, y, obj_Wall))
    {
        while (!place_meeting(x + sign(hspd), y, obj_Wall))
        {
            x = x + sign(hspd);
        }
        hspd = 0;
    }
    
     
  4. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    9
    I don't understand :(

    I've tried the exactely same code on an other little game and it works ! I don't understand why he doesn't work on this game :(

    Please somebody help me
     
  5. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    9
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,032
    Are you sure that's actually a obj_Wall and not a different type of object?
     

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