collision problem

E

erys

Guest
does someone knows why it happens ?

// controls

press_right = keyboard_check(vk_right)
press_left = keyboard_check(vk_left)
press_jump = keyboard_check_pressed(vk_space)

// mouvements

var move = press_right - press_left;
hspd = move * walkspd;
vspd = vspd + grav;

if (place_meeting(x, y + 1, oMur)) && (press_jump)
{
vspd = -5;
}

// Conditions horizontales

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

// Conditions verticales
if (place_meeting(x, y + vspd, oMur))
{
while (!place_meeting(x, y + sign(vspd), oMur))
{
y = y + sign(vspd);
}
vspd = 0;
}
y = y + vspd;
 

chamaeleon

Member
Did you by any chance set gravity to a non-zero value so that in addition to your own grav variable the built-in system also kicks in? Asking because you don't show the Create event which must be setting some variables.

Also, this problem you're experiencing is an ideal candidate for learning to use the debugger and/or show_debug_message() to ensure the proper code paths are taken. For instance, if I expect to hit a wall and reduce vertical speed to 0, the first thing I'd do is put a break point inside that check somewhere to see if it ever gets there.
 
E

erys

Guest
fixed it, it was the hitboxes that didnt work (and i deleted the ! before the whiles) in this version but now the controls doesnt work
and i added this
//Sol
if place_meeting(x, y + vspeed,oMur){
while place_meeting(x, y + sign(vspeed),oMur) = false
{
y = y + sign(vspeed);
}
vspeed = 0;
check_sol_une_fois = 1
check_sol_temps_reel = 1
}
else{
check_sol_temps_reel = 0
}
 
Last edited by a moderator:
Top