GML [SOLVED]Help me with collision please

F

FranceVisco

Guest
Hey, I'll explain my situation quickly. I have a platform on which my character can only walk under certain conditions. I tried to use the same code with which I collided with the walls but it does not work, the character passes slowly through the platform as if they were sandblowers. You could help me understand where I'm wrong.

P.S. Sorry but it's my first time with Game Maker


// COLLISIONS WITH WALLS

if (place_meeting (x, y + 1, obj_wall)) {
vsp = key_jump * -jumpspeed
}

if (place_meeting (x + hsp, y, obj_wall)) {
while (! place_meeting (x + sign (hsp), y, obj_wall)) {
x + = sign (hsp);
}
hsp = 0;
}
x + = hsp;

if (place_meeting (x, y + vsp, obj_wall)) {
while (! place_meeting (x, y + sign (vsp), obj_wall)) {
y + = sign (vsp);
}
vsp = 0;
}
y + = vsp;



// COLLISIONS WITH PLATFORMS

if (place_meeting (x, y + 1, obj_platform)) {
vsp = key_jump * -jumpspeed
}

if (place_meeting (x + hsp, y, obj_platform)) {
while (! place_meeting (x + sign (hsp), y, obj_platform)) {
x + = sign (hsp);
}
hsp = 0;
}



if (place_meeting (x, y + vsp, obj_platform)) {
while (! place_meeting (x, y + sign (vsp), obj_platform)) {
y + = sign (vsp);
}
vsp = 0;
}
 
Last edited by a moderator:
Top