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