open-strike-2/scenes/player/server_player_controller.gd
Nikolai Rodionov dfe888a918
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Move the real player authority to server
- Add rust bindings for the server player controller
- Implement reconciliation loop for checking the player state
- Place spawners on the test map
- Add Containerfile and helm chart
2025-01-31 19:24:57 +00:00

49 lines
1.4 KiB
GDScript

class_name ServerControlledPlayer
extends CharacterBody3D
const JUMP_VELOCITY = 4.5
func _ready() -> void:
pass
@export_category("ServerControlledPlayer")
@onready var placeholder: Node3D = $'..'
var input_direction := Vector2()
var input_rotation_y
@rpc("call_local", "any_peer", "unreliable_ordered")
func set_input_direction(new_input_direction: Vector2):
input_direction = new_input_direction
@rpc("call_local", "any_peer", "unreliable_ordered")
func set_rotation_y(new_rotation_y: float):
rotation.y = new_rotation_y
@rpc("call_local", "any_peer", "unreliable_ordered")
func set_rotation_x(new_rotation_x: float):
rotation.x = new_rotation_x
@rpc("call_local", "any_peer", "unreliable_ordered")
func jump():
jumping = true
var jumping := false
func _process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
if is_on_floor() && jumping:
velocity.y = JUMP_VELOCITY
jumping = false
if is_on_floor():
var direction := (transform.basis * Vector3(input_direction.x, 0, input_direction.y)).normalized()
#if is_on_floor():
if direction:
velocity.x = direction.x * placeholder.character_speed
velocity.z = direction.z * placeholder.character_speed
else:
velocity.x = move_toward(velocity.x, 0, placeholder.character_speed)
velocity.z = move_toward(velocity.z, 0, placeholder.character_speed)
func _physics_process(delta: float) -> void:
move_and_slide()