Need Help With Platformer Slopes

Discussion in 'Programming' started by CheatingPenguin, Jul 11, 2019.

  1. CheatingPenguin

    CheatingPenguin Member

    Jul 11, 2019
    Hello everyone.

    I have a player object that is a square.
    It can move left and right, collide with walls, and jump. However, I want to add slopes. Currently, my Slope Object's parent is obj_solid. I want to figure out how to make the following code make the player look for a slope that is no more than 4 pixels, and walk up it. If the code detects that the block colliding with the player is more than 4 pixels tall, it will collide with it like a regular wall and be unable to climb up it.

    I've spent all of today and yesterday researching these forums and YouTube tutorials looking for a solution that isn't too complex. I'm looking for a solution that is basic as I am a beginner.

    Here is my Horizontal Collision code:
    // Horizontal Collision
    if (place_meeting(x + hspd, y, obj_solid)) {
       while(!place_meeting(x + sign(hspd), y, obj_solid)) {
           x += sign(hspd);
       hspd = 0;
    x += hspd;
    Any ideas? I tried Shaun's YouTube tutorial, but if the slope was too steep, the player's speed would halt and then continue.

    If you have any questions or ideas, please let me know.


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