crouching, walking and jumping
This commit is contained in:
parent
58ccdbce0e
commit
f312e0a4a6
9 changed files with 71 additions and 60 deletions
|
|
@ -8,22 +8,22 @@ extends State
|
|||
@export var stand_up_area: Area3D
|
||||
@export var player: Player
|
||||
@export var player_movement: PlayerMovement
|
||||
@export var player_input: PlayerInput
|
||||
@export var animation_player: AnimationPlayer
|
||||
@export var crouch_time: float = 0.1
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
||||
func enter() -> void:
|
||||
animation_player.play("crouch",-1,1/crouch_time)
|
||||
player_input.crouch_end.connect(try_end_crouch)
|
||||
|
||||
func exit() -> void:
|
||||
animation_player.play("crouch",-1,-1/crouch_time,true)
|
||||
player_input.crouch_end.disconnect(try_end_crouch)
|
||||
|
||||
func physics_update(delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if Input.is_action_just_pressed("plr_jump") and player.is_on_floor() and toggle:
|
||||
transition.emit("Stand")
|
||||
return
|
||||
|
||||
if not player.is_on_floor():
|
||||
transition.emit("Fall")
|
||||
|
|
@ -31,7 +31,6 @@ func physics_update(delta: float) -> void:
|
|||
|
||||
player_movement.process_movement(max_speed * weapon_system.get_speed_modifier(),acceleration,deceleration,delta)
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if (toggle == true and event.is_action_pressed("plr_crouch")) or (toggle == false and event.is_action_released("plr_crouch")):
|
||||
if stand_up_area.has_overlapping_bodies() == false:
|
||||
transition.emit("Stand")
|
||||
func try_end_crouch() -> void:
|
||||
if player.is_on_floor() and stand_up_area.has_overlapping_bodies() == false:
|
||||
transition.emit("Stand")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue