M
MrSanfrinsisco
Guest
I have always struggled with creating walls and for that reason I try to create games that don't require them however that's bad habit and I think it's about time I get this resolved. I only know of one way to create walls and that's to check the place meeting of the player and the wall object and change their movement speed to to counteract them from moving through the wall. The problem I get is if a player touches a wall they can walk but they glitch out, some parts of the wall don't allow the player to move against it, some parts do, and sometimes.. The player can faze through the wall and just walk right through it... Here's the code
Code:
//Wall Collisions
if (place_meeting(x-1, y, obj_wall)) x += playerMoveSpeed;
if (place_meeting(x+1, y, obj_wall)) x -= playerMoveSpeed;
if (place_meeting(x, y-1, obj_wall)) y += playerMoveSpeed;
if (place_meeting(x, y+1, obj_wall)) y -= playerMoveSpeed;
if (place_meeting(x-1, y-1, obj_wall)) {
x += playerMoveSpeed;
y += playerMoveSpeed;
}
if (place_meeting(x+1, y+1, obj_wall)) {
x -= playerMoveSpeed;
y -= playerMoveSpeed;
}
if (place_meeting(x+1, y-1, obj_wall)) {
x -= playerMoveSpeed;
y += playerMoveSpeed;
}
if (place_meeting(x-1, y+1, obj_wall)) {
x += playerMoveSpeed;
y -= playerMoveSpeed;
}