Fixed double-crouching
This commit is contained in:
parent
dc472515c4
commit
c1548e5451
5 changed files with 12 additions and 15 deletions
|
|
@ -2,6 +2,7 @@ extends State
|
|||
|
||||
@export var player: Player
|
||||
@export var player_movement: PlayerMovement
|
||||
@export var player_input: PlayerInput
|
||||
@export var max_speed: float = 5.0
|
||||
@export var acceleration: float
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
|
@ -18,7 +19,12 @@ func physics_update(delta: float) -> void:
|
|||
if not is_multiplayer_authority():
|
||||
return
|
||||
if player.is_on_floor():
|
||||
transition.emit("Stand")
|
||||
if player_input.compressed_states & PlayerInput.CROUCH:
|
||||
transition.emit("Crouch")
|
||||
elif player_input.compressed_states & PlayerInput.WALK:
|
||||
transition.emit("Walk")
|
||||
else:
|
||||
transition.emit("Stand")
|
||||
land_sound.multiplayer_play()
|
||||
|
||||
player.velocity += player.get_gravity() * delta
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@ func enter() -> void:
|
|||
player_input.jumped.connect(on_jumped)
|
||||
player_input.crouch_begin.connect(begin_crouch)
|
||||
player_input.walk_begin.connect(begin_walk)
|
||||
if player_input.compressed_states & PlayerInput.CROUCH:
|
||||
begin_crouch()
|
||||
elif player_input.compressed_states & PlayerInput.WALK:
|
||||
begin_walk()
|
||||
|
||||
func exit() -> void:
|
||||
player_input.jumped.disconnect(on_jumped)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ func enter() -> void:
|
|||
player_input.crouch_begin.connect(begin_crouch)
|
||||
player_input.walk_end.connect(end_walk)
|
||||
player_input.jumped.connect(on_jumped)
|
||||
if player_input.compressed_states & PlayerInput.CROUCH:
|
||||
begin_crouch()
|
||||
|
||||
func exit() -> void:
|
||||
player_input.crouch_begin.disconnect(begin_crouch)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func change_state(to_state: State) -> void:
|
|||
current_state = to_state
|
||||
current_state.enter()
|
||||
|
||||
@rpc
|
||||
@rpc("authority","call_local","reliable")
|
||||
func change_state_to_name(to_name: StringName):
|
||||
if current_state != null:
|
||||
current_state.exit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue