N
NoFontNL
Guest
Hi, I experienced problems with collison checking with one way platforms:
GIF: https://i.imgur.com/wYEeo0i.gif
This is my code:
But as you see on the gif, sometimes, there's a little space between the player and the platform, so there's no platform 1 pixel below me, so I can't jump. What do I do wrong? The par_ground works fine, as you see on the GIF. When I am 2 pixels above the one way platform, and I'm a little above the grass, I am 1 pixel above the grass. If you cannot follow me there, here's the scenario:
1. I jump on the one way platform and sometimes I land 1 pixel above the platform, but sometimes also 2 pixels.
2. I can't jump when I'm 2 pixels above the platform, because it checks for 1 pixel below me. (see jump code)
3. When I'm still 2 pixels above the platform, and I'm 1 or more pixels above the grass, I 'fall' and land perfectly on the grass.
4. But when I'm not above the grass and when I'm 2 pixels above the platform, I can't 'fall' down to land on the platform, which is working with the grass.
GIF: https://i.imgur.com/wYEeo0i.gif
This is my code:
Code:
// Jump code:
if (keyJump and
(place_meeting(x,y+1,par_ground)or
(place_meeting(x,y+1,obj_oneway) and
vsp >=0))) {
vsp = -jSpeed
}
// Collison checking code, first ground, then checks for platform.
if (place_meeting(x,y+vsp,par_ground)) {
while (!place_meeting(x,y+sign(vsp),par_ground)) {
y+= sign(vsp);
}
vsp = 0
}
with (obj_oneway)
{
//if player is above it
if (other.bbox_bottom <= bbox_top)
{
//collision checks with player (other)
if (instance_place(x,y-other.vsp,other)) {
while (!place_meeting(x,y-1,other)) {
other.y+= 1;
}
other.vsp = 0
}
}
}
y+=vsp;
1. I jump on the one way platform and sometimes I land 1 pixel above the platform, but sometimes also 2 pixels.
2. I can't jump when I'm 2 pixels above the platform, because it checks for 1 pixel below me. (see jump code)
3. When I'm still 2 pixels above the platform, and I'm 1 or more pixels above the grass, I 'fall' and land perfectly on the grass.
4. But when I'm not above the grass and when I'm 2 pixels above the platform, I can't 'fall' down to land on the platform, which is working with the grass.
Last edited by a moderator: