multiplayer
This commit is contained in:
parent
aa35ee5975
commit
0dc6247f91
22 changed files with 298 additions and 14 deletions
|
|
@ -10,7 +10,7 @@ extends CharacterBody3D
|
|||
@export var TOGGLE_CROUCH: bool = true
|
||||
@export var WALK_MODIFIER: float = 0.5
|
||||
|
||||
var crouched: bool = false:
|
||||
@export var crouched: bool = false:
|
||||
set(value):
|
||||
if value != crouched and stand_up_area.has_overlapping_bodies() == false:
|
||||
crouched = value
|
||||
|
|
@ -22,11 +22,18 @@ var crouched: bool = false:
|
|||
|
||||
var potential_crouched: bool = crouched
|
||||
|
||||
func _enter_tree() -> void:
|
||||
set_multiplayer_authority(str(name).to_int())
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if potential_crouched != crouched:
|
||||
crouched = potential_crouched
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
|
@ -55,6 +62,8 @@ func update_crouch():
|
|||
animation_player.play("Crouch",-1,-1/CROUCH_TIME,true)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if event.is_action_pressed("plr_crouch"):
|
||||
if TOGGLE_CROUCH:
|
||||
crouched = not crouched
|
||||
|
|
@ -62,3 +71,7 @@ func _input(event: InputEvent) -> void:
|
|||
crouched = true
|
||||
elif event.is_action_released("plr_crouch") and TOGGLE_CROUCH == false:
|
||||
crouched = false
|
||||
if event.is_action_pressed("plr_drop"):
|
||||
var grenade = preload("res://scenes/smoke.tscn").instantiate()
|
||||
get_tree().current_scene.add_child(grenade)
|
||||
grenade.global_position = global_position + Vector3.UP * 0.5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue