Move the real player authority to server
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- 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
This commit is contained in:
48
scenes/player/server_player_controller.gd
Normal file
48
scenes/player/server_player_controller.gd
Normal file
@ -0,0 +1,48 @@
|
||||
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()
|
Reference in New Issue
Block a user