2024-02-07 22:04:19 +00:00
|
|
|
class_name ProxyController
|
|
|
|
extends Controller
|
|
|
|
|
2024-02-23 19:13:46 +00:00
|
|
|
@export var interpolation_speed := 5.0
|
2024-02-07 22:04:19 +00:00
|
|
|
|
2024-02-15 17:06:44 +00:00
|
|
|
var player: Player
|
2024-02-07 22:04:19 +00:00
|
|
|
var server_position: Vector3
|
|
|
|
|
|
|
|
func _init(new_player: Player):
|
|
|
|
player = new_player
|
2024-02-15 15:28:27 +00:00
|
|
|
name = "Controller"
|
2024-02-07 22:04:19 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
server_position = player.position
|
|
|
|
|
2024-02-23 19:13:46 +00:00
|
|
|
func _physics_process(delta: float):
|
2024-02-26 22:50:56 +00:00
|
|
|
if absf(server_position.x - player.position.x) < 0.001 && absf(server_position.z - player.position.z) < 0.001:
|
|
|
|
return
|
|
|
|
|
2024-02-15 17:06:44 +00:00
|
|
|
var time := interpolation_speed * delta
|
2024-02-16 11:51:05 +00:00
|
|
|
player.position.x = Math.dampf(player.position.x, server_position.x, time)
|
|
|
|
player.position.z = Math.dampf(player.position.z, server_position.z, time)
|