add attack and stop animations
This commit is contained in:
@@ -12,10 +12,12 @@ func _ready() -> void:
|
||||
assert(_player, "_player missing!")
|
||||
Music.track_started.connect(_on_music_track_started)
|
||||
_set_bpm()
|
||||
_attack.attacked.connect(_on_attack_attacked)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_bone_flipper.flip = _is_left()
|
||||
var has_input_prev := _has_input
|
||||
|
||||
_speed = _player.velocity.length() / _player.movement.move_speed
|
||||
_has_input = (
|
||||
@@ -35,6 +37,12 @@ func _process(_delta: float) -> void:
|
||||
Debugger.text("velocity_blend", velocity_blend, 2)
|
||||
set(&"parameters/locomotion/run/blend_position", velocity_blend)
|
||||
|
||||
if has_input_prev != _has_input:
|
||||
if _has_input:
|
||||
_abort_oneshots()
|
||||
else:
|
||||
_run_to_idle()
|
||||
|
||||
|
||||
func _is_left() -> bool:
|
||||
return _attack.side == PlayerAttack.Side.LEFT
|
||||
@@ -44,5 +52,20 @@ func _set_bpm() -> void:
|
||||
set(&"parameters/main_time_scale/scale", Music.bpm_factor)
|
||||
|
||||
|
||||
func _run_to_idle() -> void:
|
||||
set(
|
||||
&"parameters/run->idle_oneshot/request",
|
||||
AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE
|
||||
)
|
||||
|
||||
|
||||
func _abort_oneshots() -> void:
|
||||
set(&"parameters/hit_oneshot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
|
||||
|
||||
|
||||
func _on_attack_attacked() -> void:
|
||||
set(&"parameters/hit_oneshot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
|
||||
|
||||
|
||||
func _on_music_track_started() -> void:
|
||||
_set_bpm()
|
||||
|
||||
Reference in New Issue
Block a user