• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Collision errors with ground tiles and platform objects?

B

bigtunacan

Guest
Stupid bug; I fixed it, but I don't know how to delete my own posts?

----------

I'm trying to make have my character jump and land on either static unmoving tiles in a tile layer, or on platform objects that are moving around.

I've screwed something up in my collision detections though. Landing on "tiles" works correctly, but when landing on platform "objects" the player stops midair way above where the platform is actually located.

Code:
if(falling == true) {
    if(sprite_index != spr_santa_falling) {
        sprite_index = spr_santa_falling;
    }
  
    // TODO: Finish this and see why jumping is wonky
    if(tilemap_get_at_pixel(tilemap_ground, x, bbox_bottom + jumpspeed) != 0){
        falling = false;
        sprite_index = spr_santa_walk;
      
        var i = 0;
        while(tilemap_get_at_pixel(tilemap_ground, x, bbox_bottom + i) == 0) {
            i = i + 1;
        }
        y = y + i;
    }
    // Check if Santa is colliding with a platform object (brick)
    else if(place_meeting(bbox_left, bbox_bottom + jumpspeed, obj_brick2) ||
        place_meeting(bbox_right, bbox_bottom + jumpspeed, obj_brick2)) {
          
        var i = 0; 
        while (!(place_meeting(bbox_left, bbox_bottom + i, obj_brick2) ||
               place_meeting(bbox_right, bbox_bottom + i, obj_brick2))) {
              
                i = i + 1;
                y = y + 1;
        }

        falling = false;
        //y = y + i;
        sprite_index = spr_santa_walk;
        show_debug_message("I was");
        show_debug_message(i);
    } else {
        y = y + jumpspeed;
    }

}
 
Last edited by a moderator:
Top