25 lines
765 B
GDScript
25 lines
765 B
GDScript
class_name ProxyController
|
|
extends Controller
|
|
|
|
@export var interpolation_speed := 20.0
|
|
|
|
var player: Player
|
|
var movement: MovementComponent
|
|
var server_position: Vector3
|
|
|
|
func _init(new_player: Player):
|
|
player = new_player
|
|
name = "Controller"
|
|
process_physics_priority = 1
|
|
|
|
func _ready():
|
|
movement = player.movement
|
|
server_position = player.position
|
|
|
|
func _physics_process(delta: float):
|
|
if absf(server_position.x - movement.physics_position.x) < 0.001 && absf(server_position.z - movement.physics_position.z) < 0.001:
|
|
return
|
|
|
|
var time := interpolation_speed * delta
|
|
movement.physics_position.x = Math.dampf(movement.physics_position.x, server_position.x, time)
|
|
movement.physics_position.z = Math.dampf(movement.physics_position.z, server_position.z, time) |