|
|
|
|
@ -28,15 +28,15 @@ func _physics_process(delta):
|
|
|
|
|
velocity.x = direction.x * speed
|
|
|
|
|
velocity.z = direction.z * speed
|
|
|
|
|
move_and_slide()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_on_floor() and Input.is_action_just_pressed("jump"):
|
|
|
|
|
velocity.y = jump_speed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
var interp_value = remap_range(
|
|
|
|
|
Time.get_ticks_msec(),
|
|
|
|
|
snapshot_interp_start,
|
|
|
|
|
snapshot_interp_end,
|
|
|
|
|
Time.get_ticks_msec(),
|
|
|
|
|
snapshot_interp_start,
|
|
|
|
|
snapshot_interp_end,
|
|
|
|
|
STATE_INTERP_MIN,
|
|
|
|
|
STATE_INTERP_MAX
|
|
|
|
|
)
|
|
|
|
|
@ -61,18 +61,18 @@ func _get_sync_state():
|
|
|
|
|
encoder.encode_float(12, transform.origin.y)
|
|
|
|
|
encoder.encode_float(16, transform.origin.z)
|
|
|
|
|
return encoder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _set_sync_state(value):
|
|
|
|
|
assert(
|
|
|
|
|
typeof(value) == TYPE_PACKED_BYTE_ARRAY and value.size() == 20,
|
|
|
|
|
"Invalid `sync_state` array type or size (must be TYPE_RAW_ARRAY of size 20)."
|
|
|
|
|
typeof(value) == TYPE_PACKED_BYTE_ARRAY and value.size() == 20,
|
|
|
|
|
"Invalid `sync_state` array type or size (must be TYPE_RAW_ARRAY of size 20)"
|
|
|
|
|
)
|
|
|
|
|
var time_tag: int = value.decode_u64(0)
|
|
|
|
|
if time_tag > last_snapshot_tag:
|
|
|
|
|
var snapshot_time_diff = time_tag - last_snapshot_tag
|
|
|
|
|
if global_transform:
|
|
|
|
|
global_transform.origin = target_origin # Override last origin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snapshot_interp_start = Time.get_ticks_msec()
|
|
|
|
|
snapshot_interp_end = Time.get_ticks_msec() + snapshot_time_diff
|
|
|
|
|
last_snapshot_tag = time_tag
|
|
|
|
|
|