Tweening custom humanoids/npcs locally

What I currently have is that the server moves the character every 1/20 second and what I need to do now is to make it tween locally. I just have no idea how I would do it. I tried TweenService but it only made it look worse (teleporting back and forth a lot and make it stutter).
If TweenService is the solution, I would hope to get some advice on how to smoothly tween it that way (considering that the server refreshes it every 1/20 second and the client doesnt know when the NPC is going to be repositioned again).

The server only creates the HumanoidRootPart and the client is creating the rest locally. (Pretty much what @ScriptOn said on another thread edit: might have misunderstood him, since he only said torso)

What it looks like currently
on the client:
https://i.gyazo.com/ab9435586de037f6dc2b5621dde2afab.mp4
on the server:
https://i.gyazo.com/5ae9d4f29e11172f36b523d362dee554.mp4

It doesn’t look to bad in the video above, but with smooth 60FPS you obviously see the NPC teleporting.

Any help and ideas on how to do it would be appreciated.

If the duration of your Tween is exactly the same as the interval it takes for the client to receive the NPC’s next updated location, then the effect should be seamless. We can’t know how much time it’s going to take for the client to receive the next info, accounting for latency we can only guess.

So you could simulate where they’re likely to be, given speed and direction. If they’re chasing a target, you could set that target as an ObjectValue within the NPC and the client can lerp based on that.

Alternatively you could keep the NPCs static on the server and strictly move them on the clients based on their speed, target/route, and the time they began moving. The server would keep the hard-copy of the NPC’s simulated location and relay it to clients to avoid massive desync, periodically and when the NPC receives new orders.

2 Likes