Files
MovementTests/godot_state_charts_examples/automatic_transitions/automatic_transitions_demo.tscn
Minimata af1f6da98d
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 31s
Create tag and build when new code gets to main / Test (push) Has been cancelled
Create tag and build when new code gets to main / Export (push) Has been cancelled
updating project files
2026-01-28 09:50:10 +01:00

200 lines
9.4 KiB
Plaintext

[gd_scene format=3 uid="uid://huy14b6x10bh"]
[ext_resource type="Texture2D" uid="uid://bgswg1pgd01d1" path="res://godot_state_charts_examples/platformer/ninja_frog/full.png" id="2_dka03"]
[ext_resource type="Script" uid="uid://couw105c3bde4" path="res://addons/godot_state_charts/state_chart.gd" id="3_7ryss"]
[ext_resource type="Script" uid="uid://jjduf53mb1hc" path="res://godot_state_charts_examples/automatic_transitions/the_frog.gd" id="3_q65wd"]
[ext_resource type="Script" uid="uid://jk2jm1g6q853" path="res://addons/godot_state_charts/compound_state.gd" id="4_64ox6"]
[ext_resource type="Script" uid="uid://cytafq8i1y8qm" path="res://addons/godot_state_charts/atomic_state.gd" id="5_ooc8l"]
[ext_resource type="Script" uid="uid://c1vp0ojjvaby1" path="res://addons/godot_state_charts/parallel_state.gd" id="5_uojl1"]
[ext_resource type="PackedScene" uid="uid://bcwkugn6v3oy7" path="res://addons/godot_state_charts/utilities/state_chart_debugger.tscn" id="6_xggmu"]
[ext_resource type="Script" uid="uid://cf1nsco3w0mf6" path="res://addons/godot_state_charts/transition.gd" id="7_v4wmr"]
[ext_resource type="Script" uid="uid://dn780r00o0xam" path="res://godot_state_charts_examples/automatic_transitions/stamina_bar.gd" id="9_rtmjc"]
[ext_resource type="Script" uid="uid://bambbrd2wupx0" path="res://addons/godot_state_charts/state_is_active_guard.gd" id="10_caxti"]
[ext_resource type="Script" uid="uid://dgd4i8hrrxfvm" path="res://addons/godot_state_charts/not_guard.gd" id="11_rfa1s"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2fogg"]
size = Vector2(275, 15)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tsftx"]
size = Vector2(18.5, 227)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bocu2"]
radius = 15.0
height = 32.0
[sub_resource type="Resource" id="Resource_m8fyc"]
script = ExtResource("10_caxti")
state = NodePath("../../../Walking Control/Needs Rest")
[sub_resource type="Resource" id="Resource_4i0ee"]
script = ExtResource("10_caxti")
state = NodePath("../../../Walking Control/Needs Rest")
[sub_resource type="Resource" id="Resource_br5hd"]
script = ExtResource("11_rfa1s")
guard = SubResource("Resource_4i0ee")
[sub_resource type="Animation" id="Animation_nb642"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_wtk5r"]
resource_name = "pulsate"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5, 1),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ghdrh"]
_data = {
&"RESET": SubResource("Animation_nb642"),
&"pulsate": SubResource("Animation_wtk5r")
}
[node name="Node2D" type="Node2D" unique_id=1567464787]
[node name="StateChartDebugger" parent="." unique_id=601586270 instance=ExtResource("6_xggmu")]
offset_left = 293.0
offset_top = 10.0
offset_right = 624.0
offset_bottom = 441.0
initial_node_to_watch = NodePath("../TheFrog/StateChart")
[node name="Borders" type="StaticBody2D" parent="." unique_id=1992267225]
[node name="Top" type="CollisionShape2D" parent="Borders" unique_id=90904661]
position = Vector2(139.25, 170)
shape = SubResource("RectangleShape2D_2fogg")
[node name="Bottom" type="CollisionShape2D" parent="Borders" unique_id=69715327]
position = Vector2(143.25, 385)
shape = SubResource("RectangleShape2D_2fogg")
[node name="Left" type="CollisionShape2D" parent="Borders" unique_id=1956694816]
position = Vector2(11, 280.5)
shape = SubResource("RectangleShape2D_tsftx")
[node name="Right" type="CollisionShape2D" parent="Borders" unique_id=539121000]
position = Vector2(268.25, 276)
shape = SubResource("RectangleShape2D_tsftx")
[node name="TheFrog" type="CharacterBody2D" parent="." unique_id=391768475]
unique_name_in_owner = true
position = Vector2(65.25, 288)
script = ExtResource("3_q65wd")
[node name="Icon" type="Sprite2D" parent="TheFrog" unique_id=868021493]
texture = ExtResource("2_dka03")
region_enabled = true
region_rect = Rect2(0, 0, 32, 32)
[node name="CollisionShape2D" type="CollisionShape2D" parent="TheFrog" unique_id=133549938]
shape = SubResource("CapsuleShape2D_bocu2")
[node name="StateChart" type="Node" parent="TheFrog" unique_id=554953526]
unique_name_in_owner = true
script = ExtResource("3_7ryss")
track_in_editor = true
[node name="ParallelState" type="Node" parent="TheFrog/StateChart" unique_id=394795557]
script = ExtResource("5_uojl1")
[node name="Walking Control" type="Node" parent="TheFrog/StateChart/ParallelState" unique_id=2007824584]
script = ExtResource("4_64ox6")
initial_state = NodePath("Can Walk")
[node name="Can Walk" type="Node" parent="TheFrog/StateChart/ParallelState/Walking Control" unique_id=1752533082]
editor_description = "In this state the frog can move around and will lose stamina. If stamina drops to 0 the frog will automatically transition to \"Needs Rest\"."
script = ExtResource("5_ooc8l")
[node name="On Exhausted To Needs Rest" type="Node" parent="TheFrog/StateChart/ParallelState/Walking Control/Can Walk" unique_id=2012645978]
editor_description = "This transition will listen to the \"exhausted\" event, triggered when the frog's stamina sinks to 0. We could also use an expression property tracking the stamina but using a dedicated event is faster and more extensible."
script = ExtResource("7_v4wmr")
to = NodePath("../../Needs Rest")
event = &"exhausted"
delay_in_seconds = "0.0"
[node name="Needs Rest" type="Node" parent="TheFrog/StateChart/ParallelState/Walking Control" unique_id=1043996323]
editor_description = "In this state the frog cannot move for 3 seconds."
script = ExtResource("5_ooc8l")
[node name="After 3 seconds To Can Walk" type="Node" parent="TheFrog/StateChart/ParallelState/Walking Control/Needs Rest" unique_id=2005599196]
editor_description = "This will automatically transition back to \"Can Walk\" after 3 seconds."
script = ExtResource("7_v4wmr")
to = NodePath("../../Can Walk")
delay_in_seconds = "3"
[node name="Animation Control" type="Node" parent="TheFrog/StateChart/ParallelState" unique_id=221930873]
editor_description = "This controls the pulsating red animation when the frog is exhausted. Note that you could also model this using state_entered and state_exited events on the \"Needs Rest\" state, which is simpler (and more performant). Its only done this way to show automatic events."
script = ExtResource("4_64ox6")
initial_state = NodePath("Normal")
[node name="Normal" type="Node" parent="TheFrog/StateChart/ParallelState/Animation Control" unique_id=636659351]
script = ExtResource("5_ooc8l")
[node name="On Needs Rest to Pulsating Red" type="Node" parent="TheFrog/StateChart/ParallelState/Animation Control/Normal" unique_id=1688116698]
editor_description = "This is another example of an automatic transition. When the \"Needs Rest\" state becomes active, this will automatically transition to the \"Pulsating Red\" state."
script = ExtResource("7_v4wmr")
to = NodePath("../../Pulsating Red")
guard = SubResource("Resource_m8fyc")
delay_in_seconds = "0.0"
[node name="Pulsating Red" type="Node" parent="TheFrog/StateChart/ParallelState/Animation Control" unique_id=286182284]
script = ExtResource("5_ooc8l")
[node name="On Not Needs Rest to Normal" type="Node" parent="TheFrog/StateChart/ParallelState/Animation Control/Pulsating Red" unique_id=432694164]
editor_description = "When the \"Needs Rest\" state becomes inactive, this will automatically transition to the \"Normal\" state."
script = ExtResource("7_v4wmr")
to = NodePath("../../Normal")
guard = SubResource("Resource_br5hd")
delay_in_seconds = "0.0"
[node name="AnimationPlayer" type="AnimationPlayer" parent="TheFrog" unique_id=374228446]
unique_name_in_owner = true
libraries/ = SubResource("AnimationLibrary_ghdrh")
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1940481045]
offset_left = 19.25
offset_top = 401.0
offset_right = 272.25
offset_bottom = 458.0
[node name="Label" type="Label" parent="VBoxContainer" unique_id=660045210]
layout_mode = 2
text = "Stamina"
[node name="StaminaBar" type="ProgressBar" parent="VBoxContainer" unique_id=1918943340]
layout_mode = 2
script = ExtResource("9_rtmjc")
[node name="Label" type="Label" parent="." unique_id=2058097452]
offset_right = 286.0
offset_bottom = 156.0
text = "This example shows automatic transitions. Move the frog with the arrow keys. If the frog loses all stamina, it automatically transitions to a state where it will be unable to move for 3 seconds."
autowrap_mode = 2
[connection signal="state_physics_processing" from="TheFrog/StateChart/ParallelState/Walking Control/Can Walk" to="TheFrog" method="_on_can_walk_state_physics_processing"]
[connection signal="state_physics_processing" from="TheFrog/StateChart/ParallelState/Walking Control/Needs Rest" to="TheFrog" method="_on_needs_rest_state_physics_processing"]
[connection signal="state_entered" from="TheFrog/StateChart/ParallelState/Animation Control/Normal" to="TheFrog" method="_on_normal_state_entered"]
[connection signal="state_entered" from="TheFrog/StateChart/ParallelState/Animation Control/Pulsating Red" to="TheFrog" method="_on_pulsating_red_state_entered"]