GMS 2 Collision Detection Issue

Raptor_Guy

Member
This seems rather simple, but I can't figure it out. When my player is in the move state, it checks every step whether there's place_meeting(x, y-1, oSolid) && place_meeting(x, y+1, oSolid), in other words, when the player is crushed between the ground and a falling block (oSolid is a parent of the ground object), correct? If it returns true, it enters into the gameover state. But when I was playtesting, this came up:
Screen Shot 2019-01-22 at 8.24.17 PM.png
I don't know why it's detecting that the player is directly on top of the solid (presumably the one to the left of it), because I have (what I believe is) pixel-perfect collision:
if (hspd != 0) {
if (place_meeting(x+hspd, y, oSolid)) {
while (!place_meeting(x+sign(hspd), y, oSolid)) {
x += sign(hspd);
}
hspd = 0;
}
}

if (vspd != 0) {
if (place_meeting(x, y+vspd, oSolid)) {
while (!place_meeting(x, y+sign(vspd), oSolid)) {
y += sign(vspd);
}
vspd = 0;
}
}
Any help is appreciated!
 

TheouAegis

Member
Make sure you round off your coordinates. It's entirely possibleyou are moving to what the game perceives as being outside of a collision then on the next step it will round off differently and you will end up in a collision. Make it so it won't need to be rounding at all.

I take it your turtle has its bounding box around its shell, ignoring the tail and the head?
 

Raptor_Guy

Member
Thanks, but I still have the same problem after rounding the x and y coordinates to the nearest 10th in the player end step event. Also, you are correct, here's the collision box:
Screen Shot 2019-01-23 at 8.41.37 AM.png

It's the same for each of the player sprites.
 
Top