From 638e4e2578ba1eda76646befe156fd4d5a46420f Mon Sep 17 00:00:00 2001 From: teatov Date: Mon, 7 Oct 2024 23:59:04 +1000 Subject: [PATCH] set unit animation to manual --- scenes/units/abstract/unit.tscn | 1 + scenes/units/ant_gatherer.tscn | 3 +++ scripts/units/unit.gd | 6 +----- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scenes/units/abstract/unit.tscn b/scenes/units/abstract/unit.tscn index cf0063c..1690a1f 100644 --- a/scenes/units/abstract/unit.tscn +++ b/scenes/units/abstract/unit.tscn @@ -17,6 +17,7 @@ collision_mask = 0 script = ExtResource("1_ulhs6") [node name="AnimationTree" type="AnimationTree" parent="."] +callback_mode_process = 2 [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0) diff --git a/scenes/units/ant_gatherer.tscn b/scenes/units/ant_gatherer.tscn index 8f673a2..0e64219 100644 --- a/scenes/units/ant_gatherer.tscn +++ b/scenes/units/ant_gatherer.tscn @@ -51,6 +51,9 @@ bones/43/scale = Vector3(1, 1, 1) [node name="GathererMesh" parent="AntModel/Armature/Skeleton3D" index="0"] visible = true +[node name="AnimationTree" parent="." index="1"] +callback_mode_process = 1 + [node name="Gathering" parent="." index="8" instance=ExtResource("3_7b5q8")] [node name="NearbyItemsSearch" parent="Gathering" index="0"] diff --git a/scripts/units/unit.gd b/scripts/units/unit.gd index 7f3f5bf..01a7d83 100644 --- a/scripts/units/unit.gd +++ b/scripts/units/unit.gd @@ -78,11 +78,6 @@ func _navigate() -> void: func _animate(delta: float) -> void: if not is_on_screen: - if velocity.length() > 0.1: - var velocity_normalized := velocity.normalized() - global_rotation.y = atan2( - -velocity_normalized.x, -velocity_normalized.z - ) + PI return if velocity.length() > 0.01: @@ -101,6 +96,7 @@ func _animate(delta: float) -> void: delta * 8 ) animation_tree.set("parameters/locomotion/blend_position", locomotion_value) + animation_tree.advance(delta) func _wander(delta: float) -> void: