I'm currently in the process of making a platformer, and am currently in the process of creating "depth" into my game, by making Up/Down-W/S control your depth. (Come closer to screen, go further).
The reason I chose to do this is so I can walk around stairs, go behind tables, etc.
But I have run into a problem.
When I call in my player code, if (depth == oWall.depth) {//code}, it is applying to every single wall ever. Is there a way to only make it apply to the object you are currently touching?
Here is my code so far:
/// Collision
// TODO: Make "depth" apply to a singular instance.
// \/ \/
if (depth == oWall.depth) {
/*
Colliding with a wall on the Horizontal Axis, causes the player to stop moving.
*/
if (place_meeting(x + h_speed, y, oWall)) {
while(!place_meeting(x + sign(h_speed), y, oWall)) {
x += sign(h_speed);
}
h_speed = 0;
}
/*
Colliding with a wall on the Vertical Axis, causes the player to stop moving.
*/
if (place_meeting(x, y + v_speed, oWall)) {
while(!place_meeting(x, y + sign(v_speed), oWall)) {
y += sign(v_speed);
}
v_speed = 0;
}
}
Hope you understand what I'm asking.