B
brrod
Guest
im having troubles with my collision with walls for my top down game. this is my code:
vspeed = 0;
hspeed = 0;
if(keyboard_check(ord("W"))) vspeed -= 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
if(keyboard_check(ord("S"))) vspeed += 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
if(keyboard_check(ord("A"))) hspeed -= 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
if(keyboard_check(ord("D"))) hspeed += 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
speed = clamp(speed, -4, 4);
and the collision with the wall is:
speed = 0
direction = 0
the problem with this is when im colliding with a wall i wont be able to move towards another point. lets say im pressing w and d at the same time and my back is facing the wall. i should still be able to move towards the right, but this doesnt work because he puts my speed at 0. I understand the problem but I dont know how to fix this. Im very new to game maker so any help is helpfull. thanks in advance
vspeed = 0;
hspeed = 0;
if(keyboard_check(ord("W"))) vspeed -= 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
if(keyboard_check(ord("S"))) vspeed += 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
if(keyboard_check(ord("A"))) hspeed -= 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
if(keyboard_check(ord("D"))) hspeed += 4;
if !audio_is_playing(so_footsteps) {
audio_play_sound(so_footsteps, 1, false)
}
speed = clamp(speed, -4, 4);
and the collision with the wall is:
speed = 0
direction = 0
the problem with this is when im colliding with a wall i wont be able to move towards another point. lets say im pressing w and d at the same time and my back is facing the wall. i should still be able to move towards the right, but this doesnt work because he puts my speed at 0. I understand the problem but I dont know how to fix this. Im very new to game maker so any help is helpfull. thanks in advance