[This is marked under “Scripting Support” due to it involving Heartbeat Updates and not Map Design]
I’ve been working on a re-write for my golfing game, Let’s Go Golfing! and I’ve been struggling to find a solution to the largest issue that has been causing problems for the longest time, I nicknamed it a “Part Split” where the seem of two parts meet causing weird bounces, even though the ball should bounce off like they’re a single part.
Here’s a screenshot example I made in a testing environment:
Let me be clear: The maps themselves cannot be changed to fix this, as the engine uses differing parts to determine game interactions (such as the green, sand, water, etc), so splits in parts are inevitable.
I’ve tried wrangling the physics engine before but it only caused even more problems, such as stuttering collisions, freezing, and many others.
I’ve also looked into a predictive physics model but I’ve never managed to make anything accurate, even when only trying to predict a single frame in the future. Even gone as far as looking into making a custom physics engine, but quickly backed off that idea because I want to avoid making drastic changes in physics, as doing so will force a full data wipe to a game that’s already established.
But as for right now, I’ve run out of ideas, so I’m looking for some help.
I know this is a lot to ask for so if no solution is found then it’ll have to stay for now.
Just to clarify, you’re relying purely on the Roblox physics engine using a Part with Shape set to Enum.PartType.Ball for collisions?
I attempted to replicate your testing environment (and set up a few tests of my own) and from what I can tell the unintuitive bouncing behavior arises due to the physics engine detecting multiple contact points of the “golf ball” colliding with multiple parts during a physics step or brief sequence of steps. My guess is that the engine does not treat an Enum.PartType.Ball Part as a “perfect sphere” and calculates collisions after contact (or really an intersection) occurs (this is why Parts with high velocity are sometimes able to clip through other parts).
I do not believe it is currently possible to “correct” this behavior of the physics engine. Personally, I would take the custom physics engine approach.
To my knowledge, the reason why this happens is because the ball part is moving fast enough that the physics engine will clip the corner of one of the parts after it slightly clips the ground.
I would love to do a custom physics engine, but doing so means changing a lot of fundamentals, and it’s way beyond what I’m capable of doing.
Yeah, exactly. Instead of the collision check being spherecast based (checking for intersection along a ray) it is intersection based (checking for intersections at a given position), probably for fairly substantial performance benefits. I’ve built custom spherecast physics engines in the past, so if you do end up looking into that approach feel free to reach out.