I’m trying to create a secure and smooth NPC (non-humanoid) movement system where players can shoot (using fastcast) the moving enemy.
Server controls an invisible part (for validation) and client move a local part for visualization.
Two raycasts are made every time a players shoots - One for server validation and one for client visualization.
Many suggest to instantly move the part to destination on the Server and tween on the client.
This will cause the raycast hits not to match up (see image below). The server will miss where the client hits since the parts are not at the same position.
Is there a good way to handle this kind of synced movement in an optimal way?
Where both server and client parts can move and sync in an optimal way and minimize replication between server/client?
Thanks for the suggestion. But I feel most of that info is over my head.
I think this situation I’m in must be a common issue that many devs on Roblox have ran into before.
Absolute sync between client/server might not be the best solution for this problem.
It’d be great if someone with more knowledge could pop in.
Unfortunately I think it’s just a kind of difficult problem. From my limited knowledge, the problem you described is to do “lag compensation” and the basic technique for that is time travel.
These articles describe it pretty well in layman’s terms IMO:
I tried googling for “roblox lag compensation”, unfortunately it’s not a very googleable term because there’s mostly just videos on how to fix your internet connection if you get lag in games xD
EDIT: Here’s an article w/ videos that also provides C# source code
You can create a invisible part that is the model’s size using the server and make clients create the visual model who are welded to the invisible part created by the server for them.
This shouldn’t cause “jitterness” unless if you’re not using lerp/interpolation along with DeltaTime for server hitboxes.
Use part.CFrame = part.CFrame:Lerp(newCFrame, math.min(deltatime * 10, 1))
Humanoids are actually not that bad, a lot of developers think they’re bad because of their physics and how the server handles them, some devs even try convincing others to not use them, you can just disable useless states. (i.e. Climbing, Swimming)
Also, why are you trying to create a custom replication system when Roblox already does it for you? They use way less data since it’s built-in.
All this entity interpolation and lag compensation is complete non-sense and probably not worth the time, start smaller instead of starting bigger.
This is coming from my personal experience, I have tried doing this myself, it’s not worth the time especially in Roblox.
My opinion doesn’t matter when it comes to your decisions, it’s up to you if you really want to go through the hassle of remaking replication and doing lag compensation, just letting you know!
I’m trying to reduce server strain. Lerping or Tweening 500+ NPCs smoothly on the server will take its toll. That’s why I’m trying to create acceptable movement on the server just for hitboxes yet have perfectly smooth movement on the client. I’m not looking for a perfect sync between the two.
I’m also trying to make the server/client independent of each other. So there will not be any heavy replication between the two. Just like with my bullets/raycasts where the server/client are separated.
My NPCs are not human-like things but actually more like flying spheres so I’m not using humanoids. I want these to fly smoothly in the air from different points yet allow the server to get accurate hitboxes.
Maybe this is a fool’s errand. But I felt it was worth the try to get input from the forum.