Godot Version
4.3
Question
Recently I’ve started to implement movement of players on the server and tried to reproduce the client physics with the same settings to minimize the position errors, 30 fps. For simplicity, I allowed only XY movements, box shape, 1 kg mass, 1 m/s speed and tried to run just one tick to the right. On the server side I’ve got x=0.033333
, while on the client x=0.033222
.
Can anybody tell me, from where this error comes on the client side? How to eliminate this error?
There is a code I used for the player movement:
extends RigidBody3D
@export var speed = 1.0
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
var inputDirection := Input.get_vector("left", "right", "down", "up")
var direction := (transform.basis * Vector3(inputDirection.x, inputDirection.y, 0)).normalized()
if direction:
linear_velocity.x = direction.x * speed
linear_velocity.y = direction.y * speed
else:
linear_velocity.x = 0
linear_velocity.y = 0
print("%f" % global_position.x)
I tried to play with physics settings in the Godot, but no matter what I changed there is always e=0.000111
difference between client and server x positions with the simple setup