• 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!

Windows "Snapping" to platform too fast

Y

Yelf

Guest
I'm not too sure how helpful the title is, but essentially my problem is that when falling onto my platform object (normal one-way surface kinda thing), its much faster and almost snaps into place, as compared to how falling onto a surface normally goes.

I gave myself a bit of a hard time after I decided to do collision using a tilemap early on, after I decided I wanted more flexibility. As of now, I'm running both systems in tandem, as you'll see in the code. The tilemap collision works perfectly, as for the most part does the platform code I quickly threw together.

Moving downward collision system (up not included because it doesn't affect platforms in any way)
GML:
y += dy;
if (dy > 0) //down
{
    var t1 = tilemap_get_at_pixel(collision_map, bbox_left, bbox_bottom) & tile_index_mask;
    var t2 = tilemap_get_at_pixel(collision_map, bbox_right, bbox_bottom) & tile_index_mask;
    var tmid = tilemap_get_at_pixel(collision_map, x_center,bbox_bottom) & tile_index_mask;
    
    if (t1 != 0 || t2 != 0 || tmid != 0) //collision?
    {
        y = ((bbox_bottom & ~31) - 1) - sprite_bbox_bottom;
        v_speed = 0;
    }
    if (place_meeting(bbox_left, bbox_bottom,obj_platform) || place_meeting(bbox_right, bbox_bottom,obj_platform) || place_meeting(x_center, bbox_bottom,obj_platform))
    {
        v_speed = 0;
        y = obj_platform.bbox_top - 44;
    }

Jump code (unsure if this would be the problem, but it has part relating to platforms...)
GML:
//jump
var t1 = tilemap_get_at_pixel(collision_map, bbox_left, bbox_bottom + 1) & tile_index_mask;
var t2 = tilemap_get_at_pixel(collision_map, bbox_right, bbox_bottom + 1) & tile_index_mask;
var tmid = tilemap_get_at_pixel(collision_map, x_center,bbox_bottom + 1) & tile_index_mask;

if (t1 != 0 || t2 != 0 || tmid != 0 || (place_meeting(x,bbox_bottom+1,obj_platform)&&(bbox_bottom+1 = obj_platform.bbox_top)))
{
    if (keyboard_check(vk_space) && jump_delay < 0)
    {
        v_speed = -jump_impulse;
        jump_delay = 20;
    }
} else {
if (sign(v_speed) == -1)
{
    sprite_index = spr_player_air;
    image_speed = 0;
    image_index = 0;
} else
{
    sprite_index = spr_player_air;
    image_speed = 0;
    image_index = 1;
}
}
jump_delay += -1;
Some extra information, the sprite is 44x88, hence why 44 is subtracted from obj_platform.bbox_top in the downwards code. Its bbox is smaller than that though.
Here is a video of the issue: LINK
And a picture of the sprite with mask:
SpriteBBox.PNG
Additionally, if there are any better ways to share videos here, please let me know.
Any help is much appreciated!
 
Top