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.
 
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