R
Roobicorn
Guest
I'm working on a platformer in which involves the player being able to jump up through ledges, landing on top of them, or, if they can reach the ledge but can't make it over, they can grab the ledge and hang from it.
I'm expanding on some of the code from Shaun Spalding's Platformer tutorial.
I'm using !place_meeting(x, y+1, obj_ledge) to ensure that the player is in the air & not standing on a ledge, and place_meeting(x, y, obj_ledge) to detect if the player is colliding with a ledge he can grab.
The problem I'm having is that (if I understand it correctly) !place_meeting(x, y+1 ...) doesn't just check the row of pixels below the object, it checks the whole collision mask, moved down by one pixel.
so when combined with place_meeting(x, y ...), this means that the check only returns true if the top row of pixels in the collision mask collides with the object. (see image):
This is ok some of the time, but often, these pixels might not collide with the ledge depending on the speed and direction of the jump, or if the player's timing is off. and it means that the player cannot grab onto a ledge if it's at, say, his eye-level.
Is there a way I can both ensure there's no ledge-collision from below, while checking for a collision with at least the top-half of the player object?
I'm expanding on some of the code from Shaun Spalding's Platformer tutorial.
I'm using !place_meeting(x, y+1, obj_ledge) to ensure that the player is in the air & not standing on a ledge, and place_meeting(x, y, obj_ledge) to detect if the player is colliding with a ledge he can grab.
Code:
on_ledge = place_meeting(x, y + 1, obj_ledge);
over_ledge = place_meeting(x, y, obj_ledge);
(...)
//GRABBING LEDGE:
if (!on_ledge && over_ledge && key_up_held)
{
var _ledge = instance_place(x, y, obj_ledge);
to_y = _ledge.y + 8;
if (y >= to_y)
{
y = to_y;
state = HANGING;
}
}
so when combined with place_meeting(x, y ...), this means that the check only returns true if the top row of pixels in the collision mask collides with the object. (see image):
This is ok some of the time, but often, these pixels might not collide with the ledge depending on the speed and direction of the jump, or if the player's timing is off. and it means that the player cannot grab onto a ledge if it's at, say, his eye-level.
Is there a way I can both ensure there's no ledge-collision from below, while checking for a collision with at least the top-half of the player object?
Last edited by a moderator: