Stumbled upon this thread:
@Simmie's answer and others helped immensely. I was running into the same issue as OP in that thread, and Simmie's solution worked great.
How my server is setup: (I trust the client too much, but I want to get everything working before diving into more advanced stuff).
- Server tick rate is 10 times per second
- Client side network tick rate (sends positional data to server), is 10 times per second
Interpolation code (Godot)
var realPosition = Vector2()
var lastRealPosition = Vector2()
var t = 0.00
func _process(delta):
t += delta
t = clamp(t, 0, 1)
$monster.global_position = lastRealPosition.linear_interpolate(realPosition, t)
When a new message is received (server, using crystal-lang)
t = 0 # Resets on each positional update
lastRealPosition = $monster.global_position
realPosition = incoming_position # (position from server)
This works great so far. The monster sprite transitions itself towards the end position very smoothly!
However, there is one problem! It moves very, very slow and doesn't interpolate fast enough.
Is there a way to increase this so it interpolates faster? I tried doing t+= delta * 10.00, but then the lerping tries to "catch up to the player".
What could be causing that? It's hard to see, but the $monster sprite catches up to the end position, then stops.. then continues again. It's only buttery smooth if I do t += delta.