Skip to content

Commit 6cca353

Browse files
manuqwjt
authored andcommitted
Gym: Use CharacterAnimationPlayerBehavior
Add it to the character that has an InputWalkBehavior. Also add an AnimationPlayer node to it, with idle, walk and run animations. The walk and run animations have rudimentary audio tracks. Add an AudioStreamPlayer2D node for those sound effects. Keep the CharacterSpriteBehavior but disable Play Animations in it, so the character still flips horizontally.
1 parent 660c2ae commit 6cca353

1 file changed

Lines changed: 218 additions & 2 deletions

File tree

scenes/game_elements/characters/components/gym_area_test.tscn

Lines changed: 218 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=37 format=4 uid="uid://ikgvi75j5dls"]
1+
[gd_scene load_steps=44 format=4 uid="uid://ikgvi75j5dls"]
22

33
[ext_resource type="TileSet" uid="uid://07fq3rspk8ia" path="res://scenes/tileset.tres" id="1_5xpm5"]
44
[ext_resource type="SpriteFrames" uid="uid://07di3updrwh0" path="res://scenes/game_elements/characters/components/sprite_frames/storyweaver_purple.tres" id="3_6axvd"]
@@ -7,6 +7,7 @@
77
[ext_resource type="SpriteFrames" uid="uid://2ek86nvw6y28" path="res://scenes/game_elements/props/tree/components/tree_spriteframes_yellow.tres" id="5_7132a"]
88
[ext_resource type="PackedScene" uid="uid://bbsc3wssndtfe" path="res://scenes/game_elements/props/decoration/hiding_mushroom/hiding_mushroom.tscn" id="6_l45sp"]
99
[ext_resource type="PackedScene" uid="uid://dv4f232y8w8dv" path="res://scenes/game_elements/props/decoration/water_rock/water_rock.tscn" id="7_1aydi"]
10+
[ext_resource type="Script" uid="uid://b3hx1n2yl88qr" path="res://scenes/game_logic/character_animation_player_behavior.gd" id="9_1x76l"]
1011
[ext_resource type="SpriteFrames" uid="uid://b3r84ksew5djp" path="res://scenes/game_elements/characters/enemies/throwing_enemy/components/ink_drinker_frames_purple.tres" id="9_6nfeg"]
1112
[ext_resource type="Script" uid="uid://cx0sk4uhvnii0" path="res://scenes/game_logic/walk_behaviors/erratic_walk_behavior.gd" id="10_k43ew"]
1213
[ext_resource type="Script" uid="uid://q4jj6ou7yonf" path="res://scenes/game_logic/walk_behaviors/bounce_walk_behavior.gd" id="11_utmd2"]
@@ -17,6 +18,7 @@
1718
[ext_resource type="Script" uid="uid://dy68p7gf07pi3" path="res://scenes/game_logic/character_sprite_behavior.gd" id="15_utmd2"]
1819
[ext_resource type="Texture2D" uid="uid://dxaq5piwxqnht" path="res://scenes/game_elements/characters/player/components/dust.png" id="16_w4jvh"]
1920
[ext_resource type="Script" uid="uid://csev4hv57utxv" path="res://scenes/game_logic/walk_behaviors/character_speeds.gd" id="17_itker"]
21+
[ext_resource type="AudioStream" uid="uid://4ec6e2alns71" path="res://assets/third_party/sounds/characters/enemies/guard/GrassFoot.ogg" id="17_p4wnd"]
2022
[ext_resource type="SpriteFrames" uid="uid://r3dn5pxqk1sv" path="res://scenes/game_elements/characters/enemies/guard/components/storyvore_frames_gray.tres" id="17_w4jvh"]
2123
[ext_resource type="Script" uid="uid://id28maao3vdy" path="res://scenes/game_logic/walk_behaviors/path_walk_behavior.gd" id="18_wq1h3"]
2224
[ext_resource type="SpriteFrames" uid="uid://dnq8cw1cio2we" path="res://scenes/game_elements/characters/enemies/throwing_enemy/components/ink_drinker_frames_green.tres" id="20_jdub8"]
@@ -90,6 +92,204 @@ func _on_input_walk_behavior_running_changed(is_running: bool) -> void:
9092
emitting = is_running
9193
"
9294

95+
[sub_resource type="Animation" id="Animation_6nfeg"]
96+
length = 0.001
97+
tracks/0/type = "value"
98+
tracks/0/imported = false
99+
tracks/0/enabled = true
100+
tracks/0/path = NodePath("AnimatedSprite2D:animation")
101+
tracks/0/interp = 1
102+
tracks/0/loop_wrap = true
103+
tracks/0/keys = {
104+
"times": PackedFloat32Array(0),
105+
"transitions": PackedFloat32Array(1),
106+
"update": 1,
107+
"values": [&"idle"]
108+
}
109+
tracks/1/type = "value"
110+
tracks/1/imported = false
111+
tracks/1/enabled = true
112+
tracks/1/path = NodePath("AnimatedSprite2D:frame")
113+
tracks/1/interp = 1
114+
tracks/1/loop_wrap = true
115+
tracks/1/keys = {
116+
"times": PackedFloat32Array(0),
117+
"transitions": PackedFloat32Array(1),
118+
"update": 1,
119+
"values": [0]
120+
}
121+
tracks/2/type = "value"
122+
tracks/2/imported = false
123+
tracks/2/enabled = true
124+
tracks/2/path = NodePath("AudioStreamPlayer2D:volume_db")
125+
tracks/2/interp = 1
126+
tracks/2/loop_wrap = true
127+
tracks/2/keys = {
128+
"times": PackedFloat32Array(0),
129+
"transitions": PackedFloat32Array(1),
130+
"update": 0,
131+
"values": [-14.776]
132+
}
133+
134+
[sub_resource type="Animation" id="Animation_dx6fu"]
135+
resource_name = "idle"
136+
loop_mode = 1
137+
step = 0.1
138+
tracks/0/type = "value"
139+
tracks/0/imported = false
140+
tracks/0/enabled = true
141+
tracks/0/path = NodePath("AnimatedSprite2D:animation")
142+
tracks/0/interp = 1
143+
tracks/0/loop_wrap = true
144+
tracks/0/keys = {
145+
"times": PackedFloat32Array(0),
146+
"transitions": PackedFloat32Array(1),
147+
"update": 1,
148+
"values": [&"idle"]
149+
}
150+
tracks/1/type = "value"
151+
tracks/1/imported = false
152+
tracks/1/enabled = true
153+
tracks/1/path = NodePath("AnimatedSprite2D:frame")
154+
tracks/1/interp = 1
155+
tracks/1/loop_wrap = true
156+
tracks/1/keys = {
157+
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1),
158+
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
159+
"update": 1,
160+
"values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9]
161+
}
162+
163+
[sub_resource type="Animation" id="Animation_makbw"]
164+
resource_name = "run"
165+
length = 0.300005
166+
loop_mode = 1
167+
step = 0.05
168+
tracks/0/type = "value"
169+
tracks/0/imported = false
170+
tracks/0/enabled = true
171+
tracks/0/path = NodePath("AnimatedSprite2D:animation")
172+
tracks/0/interp = 1
173+
tracks/0/loop_wrap = true
174+
tracks/0/keys = {
175+
"times": PackedFloat32Array(0),
176+
"transitions": PackedFloat32Array(1),
177+
"update": 1,
178+
"values": [&"walk"]
179+
}
180+
tracks/1/type = "value"
181+
tracks/1/imported = false
182+
tracks/1/enabled = true
183+
tracks/1/path = NodePath("AnimatedSprite2D:frame")
184+
tracks/1/interp = 1
185+
tracks/1/loop_wrap = true
186+
tracks/1/keys = {
187+
"times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3),
188+
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
189+
"update": 1,
190+
"values": [0, 1, 2, 3, 4, 5, 5]
191+
}
192+
tracks/2/type = "audio"
193+
tracks/2/imported = false
194+
tracks/2/enabled = true
195+
tracks/2/path = NodePath("AudioStreamPlayer2D")
196+
tracks/2/interp = 1
197+
tracks/2/loop_wrap = true
198+
tracks/2/keys = {
199+
"clips": [{
200+
"end_offset": 0.2353,
201+
"start_offset": 0.0954,
202+
"stream": ExtResource("17_p4wnd")
203+
}, {
204+
"end_offset": 0.2353,
205+
"start_offset": 0.0954,
206+
"stream": ExtResource("17_p4wnd")
207+
}],
208+
"times": PackedFloat32Array(0, 0.15)
209+
}
210+
tracks/2/use_blend = true
211+
tracks/3/type = "value"
212+
tracks/3/imported = false
213+
tracks/3/enabled = true
214+
tracks/3/path = NodePath("AudioStreamPlayer2D:volume_db")
215+
tracks/3/interp = 1
216+
tracks/3/loop_wrap = true
217+
tracks/3/keys = {
218+
"times": PackedFloat32Array(0),
219+
"transitions": PackedFloat32Array(1),
220+
"update": 0,
221+
"values": [-7.388]
222+
}
223+
224+
[sub_resource type="Animation" id="Animation_gv2vc"]
225+
resource_name = "walk"
226+
length = 0.60001
227+
loop_mode = 1
228+
step = 0.1
229+
tracks/0/type = "value"
230+
tracks/0/imported = false
231+
tracks/0/enabled = true
232+
tracks/0/path = NodePath("AnimatedSprite2D:animation")
233+
tracks/0/interp = 1
234+
tracks/0/loop_wrap = true
235+
tracks/0/keys = {
236+
"times": PackedFloat32Array(0),
237+
"transitions": PackedFloat32Array(1),
238+
"update": 1,
239+
"values": [&"walk"]
240+
}
241+
tracks/1/type = "value"
242+
tracks/1/imported = false
243+
tracks/1/enabled = true
244+
tracks/1/path = NodePath("AnimatedSprite2D:frame")
245+
tracks/1/interp = 1
246+
tracks/1/loop_wrap = true
247+
tracks/1/keys = {
248+
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6),
249+
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
250+
"update": 1,
251+
"values": [0, 1, 2, 3, 4, 5, 5]
252+
}
253+
tracks/2/type = "audio"
254+
tracks/2/imported = false
255+
tracks/2/enabled = true
256+
tracks/2/path = NodePath("AudioStreamPlayer2D")
257+
tracks/2/interp = 1
258+
tracks/2/loop_wrap = true
259+
tracks/2/keys = {
260+
"clips": [{
261+
"end_offset": 0.0869,
262+
"start_offset": 0.0975,
263+
"stream": ExtResource("17_p4wnd")
264+
}, {
265+
"end_offset": 0.0869,
266+
"start_offset": 0.0975,
267+
"stream": ExtResource("17_p4wnd")
268+
}],
269+
"times": PackedFloat32Array(0, 0.3)
270+
}
271+
tracks/2/use_blend = true
272+
tracks/3/type = "value"
273+
tracks/3/imported = false
274+
tracks/3/enabled = true
275+
tracks/3/path = NodePath("AudioStreamPlayer2D:volume_db")
276+
tracks/3/interp = 1
277+
tracks/3/loop_wrap = true
278+
tracks/3/keys = {
279+
"times": PackedFloat32Array(0),
280+
"transitions": PackedFloat32Array(1),
281+
"update": 0,
282+
"values": [-23.869]
283+
}
284+
285+
[sub_resource type="AnimationLibrary" id="AnimationLibrary_6nfeg"]
286+
_data = {
287+
&"RESET": SubResource("Animation_6nfeg"),
288+
&"idle": SubResource("Animation_dx6fu"),
289+
&"run": SubResource("Animation_makbw"),
290+
&"walk": SubResource("Animation_gv2vc")
291+
}
292+
93293
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_itker"]
94294
radius = 13.0
95295
height = 66.0
@@ -304,9 +504,25 @@ animation = &"idle"
304504
[node name="CharacterSpriteBehavior" type="Node2D" parent="OnTheGround/CharacterBody2D4/AnimatedSprite2D" node_paths=PackedStringArray("character", "sprite")]
305505
script = ExtResource("15_utmd2")
306506
character = NodePath("../..")
507+
play_animations = false
307508
sprite = NodePath("..")
308509
metadata/_custom_type_script = "uid://dy68p7gf07pi3"
309510

511+
[node name="AnimationPlayer" type="AnimationPlayer" parent="OnTheGround/CharacterBody2D4"]
512+
libraries = {
513+
&"": SubResource("AnimationLibrary_6nfeg")
514+
}
515+
516+
[node name="CharacterAnimationPlayerBehavior" type="Node2D" parent="OnTheGround/CharacterBody2D4/AnimationPlayer" node_paths=PackedStringArray("character", "animation_player")]
517+
script = ExtResource("9_1x76l")
518+
character = NodePath("../..")
519+
animation_player = NodePath("..")
520+
metadata/_custom_type_script = "uid://b3hx1n2yl88qr"
521+
522+
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="OnTheGround/CharacterBody2D4"]
523+
volume_db = -14.776
524+
bus = &"SFX"
525+
310526
[node name="InputWalkBehavior" type="Node2D" parent="OnTheGround/CharacterBody2D4" node_paths=PackedStringArray("character")]
311527
script = ExtResource("15_k43ew")
312528
character = NodePath("..")
@@ -381,5 +597,5 @@ character = NodePath("..")
381597
[node name="ScreenOverlay" type="CanvasLayer" parent="."]
382598

383599
[connection signal="running_changed" from="OnTheGround/CharacterBody2D4/InputWalkBehavior" to="OnTheGround/CharacterBody2D4/GPUParticles2D" method="_on_input_walk_behavior_running_changed"]
384-
[connection signal="running_changed" from="OnTheGround/CharacterBody2D4/InputWalkBehavior" to="OnTheGround/CharacterBody2D4/AnimatedSprite2D/CharacterSpriteBehavior" method="on_running_changed"]
600+
[connection signal="running_changed" from="OnTheGround/CharacterBody2D4/InputWalkBehavior" to="OnTheGround/CharacterBody2D4/AnimationPlayer/CharacterAnimationPlayerBehavior" method="on_running_changed"]
385601
[connection signal="running_changed" from="OnTheGround/CharacterBody2D6/NavigationFollowWalkBehavior" to="OnTheGround/CharacterBody2D6/AnimatedSprite2D/CharacterSpriteBehavior" method="on_running_changed"]

0 commit comments

Comments
 (0)