F
FunkyFreshJJD
Guest
I am slightly new to Game Maker and have never programmed before. I am trying to add collisions to my player when it hits a wall. Here is the code:
// Collide
if place_meeting(x, y, obj_wall) and x > xprevious then {
do x -= 1 until not place_meeting(x, y, obj_wall)
};
if place_meeting(x, y, obj_wall) and x > yprevious then {
do x -= -1 until not place_meeting(x, y, obj_wall)
};
This code makes it so the player can go right up to the wall and move up and down it when still on the wall. But for some reason I cannot go on top or bottom of the wall without it putting me back to my original position. Sorry if I am bad at explaining, I will have pictures explaining this.
So when I try to collide with the wall by going to the top or bottom, it will skip my player character to the position in the bottommost picture.
Idk what I am doing wrong or what I need to add.
// Collide
if place_meeting(x, y, obj_wall) and x > xprevious then {
do x -= 1 until not place_meeting(x, y, obj_wall)
};
if place_meeting(x, y, obj_wall) and x > yprevious then {
do x -= -1 until not place_meeting(x, y, obj_wall)
};
This code makes it so the player can go right up to the wall and move up and down it when still on the wall. But for some reason I cannot go on top or bottom of the wall without it putting me back to my original position. Sorry if I am bad at explaining, I will have pictures explaining this.
So when I try to collide with the wall by going to the top or bottom, it will skip my player character to the position in the bottommost picture.
Idk what I am doing wrong or what I need to add.