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

GML Collision issue for object with variable size

Y

Yellowhill

Guest
I am making a 2d platforming game where the player character has a different height when attacking and jumping, which has lead to the player potentially getting stuck if jumping beneath a platform and attacking as his jump animation body is directly underneath the platform. I have not found a thread on this exact issue and trying the move_outside_solid command hasnt been able to solve things (unless I am doing it wrong.) Ideally I would like to resolve the issue rather than changing the animation. Any ideas?

the script I attempted to use in my collision check for this issue was

with (Obj_FloorTile)
{
if (place_meeting(x,y,other))
{
if other.solid
{
var pdir;
pdir = point_direction(other.x, other.y, x, y);
move_outside_solid(pdir, -1);
}
}
}

Any suggestions greatly appreciated
 
You could create a separate mask and make that the mask for both of the sprites, so while the sprites will differ, the collision box won't?
 
Y

Yellowhill

Guest
You could create a separate mask and make that the mask for both of the sprites, so while the sprites will differ, the collision box won't?
I have considered that but I would prefer to have the collision in the different animations to be unique to both of them, otherwise it would look as though the player is hitting their head on a space in the air below the ceiling.
 
S

Shawn Shipton

Guest
I have considered that but I would prefer to have the collision in the different animations to be unique to both of them, otherwise it would look as though the player is hitting their head on a space in the air below the ceiling.
I believe RefresherTowel is referring to switching the masks dependant on what the player is doing...
Code:
if (attacking) mask_index = spr_attacking;
if (jumping) mask_index = spr_jumping;
...
This does not change the sprite of the player, only changes the "hitbox" mask
 
Top