Adds player attacking and blocking states
parent
1660300a0f
commit
a1246c7557
@ -0,0 +1,41 @@
|
||||
class_name PlayerBlocking
|
||||
extends State
|
||||
|
||||
@export var AnimPlayer: AnimationPlayer
|
||||
|
||||
@export var Self: CharacterBody3D
|
||||
|
||||
func enter(params: Dictionary):
|
||||
AnimPlayer.play("EnterBlock")
|
||||
Self.velocity = Vector3(0, 0, 0)
|
||||
|
||||
func exit():
|
||||
pass
|
||||
|
||||
func on_input(event: InputEvent):
|
||||
pass
|
||||
|
||||
func on_process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func on_physics_process(delta):
|
||||
|
||||
if Input.is_action_just_released("Block"):
|
||||
AnimPlayer.play("ExitBlock")
|
||||
|
||||
if Input.is_action_just_pressed("Attack"):
|
||||
state_machine.transition("PlayerAttack", {})
|
||||
return
|
||||
|
||||
Self.do_friction(delta)
|
||||
Self.face_mouse()
|
||||
Self.move_and_slide()
|
||||
|
||||
func as_string():
|
||||
return "PlayerAttack"
|
||||
|
||||
|
||||
func _on_animation_player_animation_finished(anim_name):
|
||||
if anim_name == "ExitBlock":
|
||||
state_machine.transition("PlayerIdle", {})
|
||||
Loading…
Reference in New Issue