K
Kelsi
Guest
Hi there,
Total rookie here — So I've done my collision coding and it all works as it's expected to... except for in one direction.
If my player is above, to the left or to the right of an object wall, I will collide right up against it like I'm supposed to. But if I come up on the wall from below, I collide with an invisible wall WAY before I even get close to the wall. I've looked and looked but I'm not sure what I'm doing wrong or why my collision would work fine in every direction except one.
Here is what my collision code looks like in my move_state script:
I hope my explanation makes sense. Let me know if I need to add more context. Like I said — novice here!
Total rookie here — So I've done my collision coding and it all works as it's expected to... except for in one direction.
If my player is above, to the left or to the right of an object wall, I will collide right up against it like I'm supposed to. But if I come up on the wall from below, I collide with an invisible wall WAY before I even get close to the wall. I've looked and looked but I'm not sure what I'm doing wrong or why my collision would work fine in every direction except one.
Here is what my collision code looks like in my move_state script:
Code:
// Horizontal Collisions
if (place_meeting(x+hspd, y, obj_wall)) {
while(!place_meeting(x+sign(hspd), y, obj_wall)) {
x += sign(hspd);
}
hspd = 0;
}
x += hspd;
// Vertical Collisions
if (place_meeting(x, y+vspd, obj_wall)) {
while(!place_meeting(x, y+sign(vspd), obj_wall)) {
y += sign(vspd);
}
vspd = 0;
}
y += vspd;