movement sync
This commit is contained in:
parent
daa83ce96d
commit
bb3a14ece7
13 changed files with 46 additions and 35 deletions
|
|
@ -1,7 +1,9 @@
|
|||
extends MultiplayerSynchronizer
|
||||
|
||||
class_name PlayerInput
|
||||
|
||||
#region SYNC
|
||||
var direction: Vector2
|
||||
@export var direction: Vector2
|
||||
#endregion
|
||||
|
||||
var crouching: bool = false
|
||||
|
|
@ -24,13 +26,12 @@ signal walk_end
|
|||
signal interact_begin
|
||||
signal interact_end
|
||||
|
||||
func _ready() -> void:
|
||||
set_multiplayer_authority(int(get_parent().name))
|
||||
func _process(_delta: float) -> void:
|
||||
if not is_multiplayer_authority(): return
|
||||
direction = Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority(): return
|
||||
direction = Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
||||
|
||||
if event.is_action_pressed("plr_ult"):
|
||||
switch_on_server.rpc_id(1,"ultimate")
|
||||
elif event.is_action_pressed("plr_bomb"):
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ func spawn_player(id: int) -> void:
|
|||
var distance = randf_range(0,spawn_radius)
|
||||
var angle = randf_range(0,TAU)
|
||||
var new_position = global_position + Vector3.RIGHT.rotated(Vector3.UP,angle) * distance
|
||||
inst.player_id = id
|
||||
get_parent().add_child(inst)
|
||||
inst.global_position = new_position
|
||||
inst.team = team
|
||||
Loading…
Add table
Add a link
Reference in a new issue