Hacker News new | ask | show | jobs
by Tade0 18 days ago
I'm interested in knowing how the physics are realized here.

I've been working on a golf game to play with my friends and the first hurdle I had to go through was the fact that you can't just slap an off-the-shelf physics engine on it and call it a day, because over certain velocities the ball will tunnel through the walls.

4 comments

I started writing my own physics system a while back, and in January of this year started working on some tests befre realziing I was never going to get acceptable phyics on my own. In August I started using Jolt and it seems to work. So to answer your question, I am using Jolt for the physics now.
Tons of physics engines (including jolt mentioned by op) have some variation of continuous collision detection that should prevent such tunneling effects. At this point it seems more rare to not have CCD at all.
You might be interested in checking out how Visual Pinball does it. The changelong [0] for the current development version discusses all the latest physics updates since the last release and it is very comprehensive. The code is open source so you can dive into the code for it to see how it's done.

[0] https://github.com/vpinball/vpinball/blob/master/docs/Change...

I remember back in the day, that pinball physics were extremely hard to write.

The main issue was "bouncy ball" physics. At certain angles, balls should roll along the edge and continue to touch that edge. In other cases, the ball bounces of the edge. It's very hard to get both use-cases right. Anyway, you cannot seem to get it right without taking the ball spin into account.

Some things seems very simple but are actually very hard. Pinball physics is one of them. The other I know of is time, super complex!