replace animation state machines with blend trees

This commit is contained in:
2024-10-22 10:46:20 +10:00
parent 6f34c70848
commit d38d87f0a3
5 changed files with 84 additions and 64 deletions

View File

@@ -24,9 +24,6 @@ var _advance_anim_delta_accum: float = 0
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
@onready var ui_origin: Node3D = $UiOrigin
@onready var animation_tree: AnimationTree = $AnimationTree
@onready var animation_playback: AnimationNodeStateMachinePlayback = (
animation_tree.get("parameters/playback")
)
@onready var anim_advance_indicator: VisualInstance3D = $AnimAdvanceIndicator
@onready var visibility_notifier: VisibleOnScreenNotifier3D = (
$VisibleOnScreenNotifier3D
@@ -116,7 +113,7 @@ func _handle_animation(delta: float) -> void:
velocity.length() / _move_speed,
delta * LOCOMOTION_CHANGE_SPEED
)
animation_tree.set("parameters/locomotion/blend_position", _locomotion_value)
animation_tree["parameters/locomotion_blend/blend_amount"] = _locomotion_value
_advance_anim_delta_accum += delta

View File

@@ -88,7 +88,9 @@ func _handle_honeydew_spawn(delta: float) -> void:
_put_honeydew(new_honeydew)
audio_player.play_sound(SoundManager.aphid_poop())
animation_playback.travel("plop")
animation_tree["parameters/plop_oneshot/request"] = (
AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE
)
_set_spawn_timer()

View File

@@ -146,7 +146,9 @@ func _pick_up() -> void:
_get_nth_pile_pos(_carrying_items.size() - 1)
).tween_finished
audio_player.play_sound(SoundManager.pop())
_unit.animation_playback.travel("plop_down")
_unit.animation_tree["parameters/plop_down_oneshot/request"] = (
AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE
)
await get_tree().create_timer(_pickup_interval).timeout
@@ -171,7 +173,9 @@ func _deposit() -> void:
return
var item := _carrying_items.pop_back() as Honeydew
_unit.animation_playback.travel("plop_up")
_unit.animation_tree["parameters/plop_up_oneshot/request"] = (
AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE
)
audio_player.play_sound(SoundManager.swoosh())
await item.start_tweening(