How to stop units from over shooting when high lag/ping?

I have a system where units are moved with LinearVelocity move to a given target (in my case where the mouse clicks) This works fine with basically no lag but when there is lag (200+ ping) the units over shoot shown here:

I have impletmented a system to slow them down when they close to the target but they dont slow down when there’s lag. Sometimes they can even over shoot in a way that they’ll just go around in loops like here:

Any help is appreciated!

1 Like

Maybe you could give network ownership to the units’ owner?

That ping also seems really high. Do you get that every time?

This is using roblox studio’s Incoming Replication lag but even at 200 ping its the same result

Changing the units primary part to the player ownership didnt work. Note that i am changing the LinearVelocity on the server side so it replicates to other players

You can multiply [it] by the delta time (the time before each frame).

Assuming it’s physics replication, I recommend parenting the unit to the player’s character and setting the network owner.

I am using a linearvelocity to move the unit so i dont like multiplying by deltatime will do much as roblox should do frame-independent frame calculations and I already tried setting the unit’s PrimaryPart’s (the LinearVelocity is in the PrimaryPart) network owner to the player but it didnt work, still over shoots

You can use :Lerp() to prevent overshooting, though it might not work for you. It doesn’t hurt to try it, though.

It works but before I can lerp the Position to the goal the units still over shoots before if happens creating a jarring teleporting effect which I want to avoid

Are you doing this on the client or server? The problem usually happens when you mix both together.

All the moving is happening on server side (including the lerping i just added) the only client side thing is sending a position to the server of where i want the units to move to

You could also try setting the network owner as nil, which should prevent the server from automatically changing the network owner as the units move around.

but wouldn’t setting it to nil make the owner the server? or do i set it nil then set it to the player?

If you explicitly set nil as the network owner then I believe the server will stop automatically transferring ownership to nearby clients, which might be the reason for the stutters.

That, or you can go the route where you set the units’ owner as the network owner, but then the server won’t be able to move them, the client will need to run the physics for their movement.

1 Like

THAT WORK, Thank you and everyone who helped