26 lines
570 B
GDScript3
Raw Normal View History

2024-02-07 22:04:19 +00:00
class_name ProxyController
extends Controller
## The character that we're controlling.
var player: Player
## The authoritative position on the server.
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
func _process(_delta):
var move := server_position - player.position
move.y = 0.0
2024-02-15 15:28:27 +00:00
if move.length_squared() < 0.02:
direction_changed.emit(Vector3.ZERO)
2024-02-07 22:04:19 +00:00
return
var direction := Vector3(move.x, 0, move.z).normalized()
2024-02-15 15:28:27 +00:00
direction_changed.emit(direction)