Windows Player slows down inside of a wall instead of stopping

My collisions were working fine until i changed something in my code that shouldnt have messed anything up. It caused my player to slow down and go through a wall, instead of stopping when colliding with it. I got rid of the changes that I made, that seemed to cause this issue. Once I got rid of the code and ran my game, the collisions still didn't work. I have no idea what to do. Here is my code for collisions.
 

Attachments

Your code looks fine to me. Perhaps there is something else constantly trying to restart moveX/moveY, or something else which changes the x/y position?

If I were you, I would try running in debug mode and check that the code sets the x/y position right and stops moveX/moveY. Then let it pass a frame and see if any of those variables have changed unexpectedly by the time you reach that same chunk of code again.
 

NightFrost

Member
That doesn't seem to be the cause. The loops only change a coordinate when there is no collision, and zero the move variable when there is a collision (you probably have x += moveX and y += moveY afterwards, the code makes sure they receive zeroes on collision). Something else may be affecting the position.
 

Yal

šŸ§ *penguin noises*
GMC Elder
Debug messages are your friend. Try adding in show_debug_message calls at appropriate places (e.g. before you change the speed variables, and before/after you move) to check if the variables have the values you expected them to (e.g. zero if there is a collision). Having some hardcoded strings at the right places (e.g. show_debug_message("COLLISION FOUND") inside the code block that's only taken when there's a collision) could help you verify whether the things you think are happening, are in fact happening.

(debug messages show up in the compile output window)
 
Top