From df940e2ba6ae2f65d1e8254d85fe6150784ecceb Mon Sep 17 00:00:00 2001 From: Rendo Date: Mon, 7 Jul 2025 23:27:36 +0500 Subject: [PATCH] Zombie animation now supports timescale --- scenes/entities/Zombies/hobo.tscn | 17 ++++++++++++++--- scenes/entities/Zombies/zombie.tscn | 15 +++++++++++++-- .../zombies/behaviours/HoboBehaviour.cs | 3 +-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/scenes/entities/Zombies/hobo.tscn b/scenes/entities/Zombies/hobo.tscn index 29ad27b..8751989 100644 --- a/scenes/entities/Zombies/hobo.tscn +++ b/scenes/entities/Zombies/hobo.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=46 format=3 uid="uid://bgqmwsb6ynm81"] +[gd_scene load_steps=48 format=3 uid="uid://bgqmwsb6ynm81"] [ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="1_fnu7s"] [ext_resource type="Shader" uid="uid://d0eo5uuj222c4" path="res://assets/shaders/CG_color_blender.gdshader" id="2_6qr4h"] @@ -152,6 +152,8 @@ _data = { &"run": SubResource("Animation_5selg") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2q05d"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_h0rfo"] animation = &"basic_zombie/eat" @@ -219,7 +221,15 @@ states/hobo_zombie_can_destroy/position = Vector2(368, 206) states/hobo_zombie_run/node = SubResource("AnimationNodeAnimation_c1y3b") states/hobo_zombie_run/position = Vector2(866, 89) transitions = ["Start", "basic_zombie_idle", SubResource("AnimationNodeStateMachineTransition_vxhht"), "basic_zombie_idle", "basic_zombie_eat", SubResource("AnimationNodeStateMachineTransition_y2ivb"), "basic_zombie_walk", "basic_zombie_eat", SubResource("AnimationNodeStateMachineTransition_7d3k4"), "basic_zombie_idle", "basic_zombie_walk", SubResource("AnimationNodeStateMachineTransition_qg8rq"), "basic_zombie_idle", "hobo_zombie_run", SubResource("AnimationNodeStateMachineTransition_4248q"), "hobo_zombie_run", "basic_zombie_eat", SubResource("AnimationNodeStateMachineTransition_tu6af"), "basic_zombie_eat", "hobo_zombie_run", SubResource("AnimationNodeStateMachineTransition_yalvk"), "hobo_zombie_can_destroy", "basic_zombie_idle", SubResource("AnimationNodeStateMachineTransition_7jlle"), "basic_zombie_eat", "basic_zombie_walk", SubResource("AnimationNodeStateMachineTransition_w1b1s"), "basic_zombie_walk", "hobo_zombie_run", SubResource("AnimationNodeStateMachineTransition_02fim")] -graph_offset = Vector2(55, -28) +graph_offset = Vector2(210, 91) + +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_txjqc"] +graph_offset = Vector2(-447, 53) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2q05d") +nodes/TimeScale/position = Vector2(60, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_xg3p6") +nodes/Tree/position = Vector2(-220, 120) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] [sub_resource type="Resource" id="Resource_4248q"] resource_local_to_scene = true @@ -277,7 +287,7 @@ autoplay = "baisc_zombie/walk" speed_scale = 3.0 [node name="AnimationTree" parent="." index="4"] -tree_root = SubResource("AnimationNodeStateMachine_xg3p6") +tree_root = SubResource("AnimationNodeBlendTree_txjqc") advance_expression_base_node = NodePath("../Behaviour") [node name="Mover" parent="." index="5"] @@ -285,6 +295,7 @@ _speed = SubResource("Resource_4248q") [node name="CanArmor" type="Node" parent="." index="7"] script = ExtResource("4_w8pya") +MaxHP = 385.0 metadata/_custom_type_script = "uid://fd4im1fmwc5n" [node name="Behaviour" type="Node" parent="." index="8" node_paths=PackedStringArray("_eatBox", "_animationTree")] diff --git a/scenes/entities/Zombies/zombie.tscn b/scenes/entities/Zombies/zombie.tscn index c243a43..a4db44c 100644 --- a/scenes/entities/Zombies/zombie.tscn +++ b/scenes/entities/Zombies/zombie.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=27 format=3 uid="uid://co11v3w8hbwgf"] +[gd_scene load_steps=29 format=3 uid="uid://co11v3w8hbwgf"] [ext_resource type="Script" uid="uid://dildme6epx8l4" path="res://scripts/components/zombies/RuntimeZombieData.cs" id="1_qq3f1"] [ext_resource type="Texture2D" uid="uid://bwdqbrnn7ygtr" path="res://assets/sprites/atlases/zombies/Зондби.png" id="2_4pdxh"] @@ -59,6 +59,16 @@ _data = { &"RESET": SubResource("Animation_qv5y7") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2q05d"] + +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_ccrjo"] +graph_offset = Vector2(-447, 53) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2q05d") +nodes/TimeScale/position = Vector2(60, 120) +nodes/Tree/node = ExtResource("8_ckb7n") +nodes/Tree/position = Vector2(-240, 120) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="Resource" id="Resource_ckb7n"] resource_local_to_scene = true script = ExtResource("7_b3p4o") @@ -106,9 +116,10 @@ libraries = { } [node name="AnimationTree" type="AnimationTree" parent="."] -tree_root = ExtResource("8_ckb7n") +tree_root = SubResource("AnimationNodeBlendTree_ccrjo") advance_expression_base_node = NodePath("../Eatbox") anim_player = NodePath("../AnimationPlayer") +parameters/TimeScale/scale = 1.0 [node name="Mover" type="Node" parent="."] script = ExtResource("4_u5syx") diff --git a/scripts/components/zombies/behaviours/HoboBehaviour.cs b/scripts/components/zombies/behaviours/HoboBehaviour.cs index 86cc9a6..dd0dd8d 100644 --- a/scripts/components/zombies/behaviours/HoboBehaviour.cs +++ b/scripts/components/zombies/behaviours/HoboBehaviour.cs @@ -11,8 +11,7 @@ public partial class HoboBehaviour : Node public void Trashed() { canDestroyed = true; - ((AnimationNodeStateMachinePlayback)_animationTree.Get("parameters/playback")).Travel("hobo_zombie_can_destroy"); - _animationTree.Set("parameters/eat_Tree/blend/blend_amount", 1.0); + ((AnimationNodeStateMachinePlayback)_animationTree.Get("parameters/Tree/playback")).Travel("hobo_zombie_can_destroy"); _eatBox._damage.SetMult(3.0f); } }