Precise Physics Issue for Hockey Game

Hey everyone,

I’ve been having a standstill with serious lag issues in my Roblox hockey game when there are multiple players in the server. Here’s how it works: players hold a power bar that goes up, and the higher it is when they release, the more power the shot has. When they hit the puck, a BodyForce is applied based on that power, and the puck moves realistically into the direction it was hit.

The problem is during actual gameplay, especially when two players pinch the puck together. (The script isn’t constantly firing when this happens, so that isn’t the issue) Also the BodyForce is destroyed after a certain amount of time or if a player hits the puck again before a new BodyForce is made. Something with BodyForces causes the puck to slide, teleport back, and then slide again, sever lag, and even freezes the puck. It makes the game super inconsistent and frustrating. It works perfectly fine when you are alone in a server, which can only be practice mode when alone.

I’ve tried many different ways of changing network ownership and even experimented with an invisible real puck and a local one that players see (which tweens to the real puck’s position). Both had the same issues.

I’m also open to alternatives that don’t use BodyForces and I’m curious how other real-time precision physics Roblox sports games handle this. Any suggestions or solutions?

Thanks!

1 Like

You may have to create your own puck system from scratch… this way you’ll have full control over everything but of course the downside is it’s difficult to create

1 Like

Thanks for the reply! Do you know of any reference I could use to help me, because I have no idea what that would consist of.

Well you’re probably going to need to have some knowledge of physics and forces… yeah and not to mention you’re going to have to basically do all the network stuff like lag compensation it’s a pretty big task i’m not gonna lie

What if you used a small debounce? Not sure how well it would work, but it might help. (Basically a lock)

if hit == false then
hit = true
-- insert code here
task.wait(0.5)
hit = false

Now don’t quote me on this, but you can also modify the Velocity property directly depending on the given power and direction. It might solve your BodyVelocity problem too, as anyone who hits the puck would alter the same value (rather than creating an entirely separate Instance). It’s definitely not the way to go due to deprecation, but I find it as the easier alternative.