GMS 2.3+ Fast moving objects sometimes passes through other solid objects


So I'm trying to make this top-down mini golf game that doesn't use room physics.

I have these 2 lines of code to bounce my golf ball in the proper direction when colliding with walls. (all set to solid objects)

if place_meeting(x, y, obj_wallshorizontal) {vspeed = vspeed * -1;}
if place_meeting(x, y, obj_wallsvertical) {hspeed = hspeed * -1;}

They work perfectly most of the time, but I noticed that if the ball goes faster, half of the time the ball just goes through the walls like nothing or sometimes even gets stuck inside them. How should I prevent this from happening?


If the movement per step of the ball is greater than the width or height of the colliding wall, there are times when it is on one side of the wall on one step, then the next step it will be on the other side, effectively jumping over the wall, as it never technically collided with it.
One way to avoid this is to limit the speed to never be greater than the width or height of a wall.
Another method is you need to do more place_meeting checks at intervals up to the max speed of the ball.


aka fel666
Unfortunately GM doesn't offer great tools to deal with this (such a vector collision, or more collision shapes).

On simple fix would be to check for collisions at multiple points along (xprevious, yprevious) (x, y).

Another option is to use collision_line().

Both methods are somewhat inaccurate in different ways, but its probably the best you can do without writing complex collisions detection code.