From ae8ac9d608b6fff21d216ea578748764b6d11316 Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Thu, 6 Mar 2025 07:16:31 -0500 Subject: [PATCH 1/6] new walk cycle --- assets/textures/player/capri.png | Bin 1045 -> 4558 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index 3f5b35c6c9e12e49128fa1e1121b5caad36e0294..3098ce17cc7a1e90515a782b84891957925789c1 100644 GIT binary patch literal 4558 zcmeHKdsGzH8J`spA^2!SqejbQAjO)_?mYH6vI_1l>{=EnY!rnQW@l$%l-*fo2UxVR zMvSO2CTK0BVgMyVW5|g~NF_-tDe)v0+o~aywn`{TOlk!oNfQl4dS`gIIj4tnn*Z26 zckb(VfA{--_q*Tj>`zTenj5|>9D<;^Hmf-e)bUaY4g$}Nr2Jk`U1c+DZkuftGzWA5 zQV|R(Bn&8uN$pvRAV^xZ7nFNJTf#_XnIc544}$jnqwSx8_R3L=v<6qqg64v{3KRmg zBSHN`gKlsKj&^*E_&BrAt@e{Zhsz!N9CxA^**GdH?>UN~KP8lJOr*V%hg z4k*)lh7YfMV#)kNg9CkCANH;2<{gz=i_R+^e&wJ@JmB)5Ue~`!@kLD(e$aNY{Sz}D z^2dR~`BB-oPQlRcm+^|ec=t+99 zO?j?BN!|S989MsNv$69Q-gAE5&sSF-jX0`LT>c}+lb;Q3u2}Sk%&Pa-KiSlGA$!U1 zwmsCARc|;Dv-nK#cV@ZTQxiiLpLlg^U8VKCoxg2e+jH9@T=-~JX*r{KxZ&yLYi~#W ztFPk+$s3w&wZWH$oPUk_Fy41xUWaFJu=BNJvGLtY&tCb<-K{~DLovVZ>OhiOy0yN7 zYaJgMyM@ptJFh%w66zrPPivt!t1s(5-c_4f!~edwvFWMzLSfS*&v|#1nsQE9|NM{d z-sIFTnQg2H zJK0>$Yea6naSnkwml4^dv14|hiOu7z+XXg#dy0eEzKt=skhN>V;{p^Q@US8c2R!*+ zKNT<{GA{+%(y$7FWr(=Vh-846GVuZntCeachFSt#5rM1;hvNj7n@Te$j#7Z05y=xp zAEip5h2K%)V^wLapDz>` z)>6cJ#puZt(rp@NkX*{;JU-beAl{VCT+BGmS19Dm7#E{r^H~od^#l9xDR_}{Plz?e zHfct7XR;w+yK(+0=rP}AFhJSul$mD=rA=*SBO=*Lxp;67-py7`=Zm0(!D6co*jxZtOYSeI-k;2N1?@@Q`^3$n*(xQ>l;-w+C{(+QL% zX;jPN;QTZMhB|e$9@T4{deZI0^#{xfo^IbN&|(9O&zC%de&h2y|6JYD-gey_YU%&H z+xT*ysN9p8QKnzbwL_MkkPqJ3w0m$@gU1>5&ax1BbMCp|7s|c*`Tzm)`}V OLN-f^`NefPyZ;SxlR9ev literal 1045 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+yeRz}TAU>>S|f?5q$_l%JNFlghxL zaenGVTaUv5BCY<>Ta`lF%LEEf1kBax=(4z`A+peEg=kc%LFG$%lT44G7#Y^MwtvynU>IFA&j%`p4O_VLWJ+=6@R zeH#|75t=XDKl_TpN9F6H{r4@zW4?Vp(=pTUtgw4WtCO^L?wPJ-ZZ^I$p{8>`{gvzw zJr_M^YtdBG-%s>;o_?8{y6&=+BU5)o6AL5PDvgCa(uTK6gLIa>h! zO^VCTyr`T|AiZNpUgjyef}PAfwvwAPcLz00v!Bm?@BE9|n;d?Ky@>w&?3&H-m&_BE zMXKgEG&?7(ak%+f_TJswcH8aW@A%yOgSq-f(JIrcLKlJYA{5{g;@Tm?@WX;(yE?=F z|NntvKu}O-sSBjoN`m}?fr3Ec&HI<^2a0eOctjR6Fz6|PFypF6cP9Y_B}!Z)N`mv# zO3D+9QW*jgGxJLH{9Hp6O!W-)jDGK7-Ud|DlN#Zf=IN=$zyaj2GDtD9GB5&JUO+4j zWrI?T1|u_AoC(M_WMpCx0Mb!FoY~F-7S95*LE!#m7KRtVgaxC~EM)-dpTN$*0#s>W zWNg5=0Aec4d-wkP?3k>KtMYw+(eY>lzLibC!ar)c z%HHPjE_m@r&~QPM`^rDz5f`^LIjICb-)qLKrI7P{?=^+1m!ejNA8j&g4!U*mmkjqU zCmF{F79n~s@(vtnnjXcwVfm@&uXe{=NDEN8zM`{booK%1i#hwZNStW0XqcaE$YJ$7 zmYP^Sa{^ZE|@nOfCSrbit{$xG=Z1KchZa@1>?fElq>uuoO#<&@d{~dT>W3M*X VWyg)<-YY@zvd$@?2>?}#qIUoQ From 3d5363374f3bf222d6f97d6a66884fce975bcc5c Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Thu, 6 Mar 2025 08:24:33 -0500 Subject: [PATCH 2/6] grounded movement and run animation scaling --- assets/textures/player/capri.png | Bin 4558 -> 4558 bytes maps/level_z.tscn | 8 +- objects/new_player/new_player.gd | 51 +++++++ objects/new_player/new_player.gd.uid | 1 + objects/new_player/new_player.tscn | 205 +++++++++++++++++++++++++++ project.godot | 32 ++++- 6 files changed, 291 insertions(+), 6 deletions(-) create mode 100644 objects/new_player/new_player.gd create mode 100644 objects/new_player/new_player.gd.uid create mode 100644 objects/new_player/new_player.tscn diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index 3098ce17cc7a1e90515a782b84891957925789c1..73426020d343a55d78f2f9a44e5dce240fd60248 100644 GIT binary patch delta 265 zcmX|*u}T9$5I{N1<)R>@w2>4!NHwrCJA1pERiIumYEIa2jLK(U+@w(TcU4jf%jiG;jzO9OVRkj#{jc z6N%-mzC5w~XLO3SFT48XuvgaO#XrA~pIb)mgmeJol>v4=fuI-=pTt?}kc}%h&FT;h bAI<$_ba%18F6YzR=Jc!zo1gXYG+kA{cSlME delta 265 zcmX|*y-EW?6om<9vx%h011Kr7un@Q~ckbNzNh{b0DXr4X9Vev^U}a??2+Dw+yC+SFfs-zhwABguiTB=e|{f5Hd(|HQUsf^-(#&nT=d{sJZ%Mih@o89 e>!Z|t)VJf|&o4cc^Vz1JPA3=bZrR<>)`LGZ{73x& diff --git a/maps/level_z.tscn b/maps/level_z.tscn index 05c748d..9a8527f 100644 --- a/maps/level_z.tscn +++ b/maps/level_z.tscn @@ -3,8 +3,8 @@ [ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_h5jcm"] [ext_resource type="Script" uid="uid://d3v13a4er2h1x" path="res://scripts/level/level.gd" id="1_hcs1r"] [ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="2_dj7w1"] -[ext_resource type="PackedScene" uid="uid://mh2gfm7iqqsm" path="res://objects/player/player.tscn" id="3_kyrxg"] [ext_resource type="PackedScene" uid="uid://c8r040r4glui4" path="res://objects/enemies/lashy/lashy.tscn" id="4_gykx6"] +[ext_resource type="PackedScene" uid="uid://bwtpsjpe2lf7l" path="res://objects/new_player/new_player.tscn" id="5_5v7mr"] [node name="LevelZ" type="Node2D"] script = ExtResource("1_hcs1r") @@ -22,8 +22,8 @@ use_parent_material = true tile_map_data = PackedByteArray("AAAAAAsAAAAAAAAAAAABAAsAAAAAAAAAAAACAAsAAAAAAAAAAAAHAAsAAAAAAAAAAAAIAAsAAAAAAAAAAAAJAAsAAAAAAAAAAAAKAAsAAAAAAAAAAAALAAsAAAAAAAAAAAANAAsAAAAAAAAAAAAOAAsAAAAAAAAAAAAPAAsAAAAAAAAAAAAQAAsAAAAAAAAAAAARAAsAAAAAAAAAAAADAAsAAAAAAAAAAAAEAAsAAAAAAAAAAAAFAAsAAAAAAAAAAAAGAAsAAAAAAAAAAAAMAAsAAAAAAAAAAAAFAAoAAAAAAAAAAAAGAAoAAAAAAAAAAAAGAAkAAAAAAAAAAAAHAAkAAAAAAAAAAAAIAAkAAAAAAAAAAAAJAAkAAAAAAAAAAAAKAAkAAAAAAAAAAAALAAkAAAAAAAAAAAAMAAkAAAAAAAAAAAALAAoAAAAAAAAAAAAKAAoAAAAAAAAAAAAJAAoAAAAAAAAAAAAIAAoAAAAAAAAAAAAHAAoAAAAAAAAAAAAMAAoAAAAAAAAAAAANAAoAAAAAAAAAAAAOAAoAAAAAAAAAAAAPAAoAAAAAAAAAAAAPAAkAAAAAAAAAAAAQAAkAAAAAAAAAAAAQAAgAAAAAAAAAAAAQAAcAAAAAAAAAAAAQAAYAAAAAAAAAAAARAAcAAAAAAAAAAAAQAAoAAAAAAAAAAAARAAkAAAAAAAAAAAARAAgAAAAAAAAAAAARAAoAAAAAAAAAAAARAAYAAAAAAAAAAAARAAUAAAAAAAAAAAARAAQAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAUAAAAAAAAAAAAFAAkAAAAAAAAAAAAEAAkAAAAAAAAAAAADAAkAAAAAAAAAAAACAAkAAAAAAAAAAAABAAkAAAAAAAAAAAABAAoAAAAAAAAAAAACAAoAAAAAAAAAAAADAAoAAAAAAAAAAAAEAAoAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAkAAAAAAAAAAAA=") tile_set = ExtResource("2_dj7w1") -[node name="Player" parent="." instance=ExtResource("3_kyrxg")] -position = Vector2(40, 124) - [node name="Lashy" parent="." instance=ExtResource("4_gykx6")] position = Vector2(141, 99) + +[node name="Player" parent="." instance=ExtResource("5_5v7mr")] +position = Vector2(37, 129) diff --git a/objects/new_player/new_player.gd b/objects/new_player/new_player.gd new file mode 100644 index 0000000..24d731c --- /dev/null +++ b/objects/new_player/new_player.gd @@ -0,0 +1,51 @@ +class_name NewPlayer +extends CharacterBody2D + + +@export_group("Ground Movement") +@export var run_acceleration: float +@export var max_run_speed: float +@export var turn_acceleration: float +@export var stopping_force: float + +@export_group("Internal References") +@export var state_chart: StateChart +@export var graphics: Node2D +@export var run_animation: SpritesheetAnimation + + +var input_dir: Vector2 = Vector2.ZERO: + set(value): + input_dir = value.sign() + state_chart.set_expression_property(&"input_dir", input_dir) + + +func _physics_process(delta: float) -> void: + move_and_slide() + state_chart.set_expression_property(&"velocity", velocity) + if velocity.x != 0.0: + graphics.scale.x = signf(velocity.x) + + input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down") + + +#region Idle +func _slow_to_stop(delta: float) -> void: + velocity.x = move_toward(velocity.x, 0.0, stopping_force * delta) +#endregion + + +#region Running +func _apply_run_acceleration(delta: float) -> void: + if absf(velocity.x) < max_run_speed: + velocity.x += input_dir.x * run_acceleration * delta + +func _scale_run_animation(delta:float) -> void: + run_animation.speed_scale = inverse_lerp(0.0, max_run_speed, absf(velocity.x)) +#endregion + + +#region Turning +func _apply_turn_acceleration(delta: float) -> void: + velocity.x += input_dir.x * turn_acceleration * delta +#endregion diff --git a/objects/new_player/new_player.gd.uid b/objects/new_player/new_player.gd.uid new file mode 100644 index 0000000..6609e5f --- /dev/null +++ b/objects/new_player/new_player.gd.uid @@ -0,0 +1 @@ +uid://dhyi4yn0xleoy diff --git a/objects/new_player/new_player.tscn b/objects/new_player/new_player.tscn new file mode 100644 index 0000000..0f8c72f --- /dev/null +++ b/objects/new_player/new_player.tscn @@ -0,0 +1,205 @@ +[gd_scene load_steps=16 format=3 uid="uid://bwtpsjpe2lf7l"] + +[ext_resource type="Script" uid="uid://dhyi4yn0xleoy" path="res://objects/new_player/new_player.gd" id="1_xs4s5"] +[ext_resource type="Texture2D" uid="uid://c71nqfyw4a3v4" path="res://assets/textures/player/capri.png" id="3_trcll"] +[ext_resource type="Script" uid="uid://cv55s54clajw5" path="res://scripts/spritesheet_animation/spritesheet_animation.gd" id="4_bsdw5"] +[ext_resource type="Script" uid="uid://bhrh1qkv7nlyl" path="res://addons/godot_state_charts/state_chart.gd" id="5_bcjtl"] +[ext_resource type="Script" uid="uid://b11v7h3ny6kh1" path="res://addons/godot_state_charts/compound_state.gd" id="6_jnxnd"] +[ext_resource type="Script" uid="uid://rrj3six8lu8p" path="res://addons/godot_state_charts/transition.gd" id="7_rgjdc"] +[ext_resource type="Script" uid="uid://b6u7unac5srh0" path="res://addons/godot_state_charts/expression_guard.gd" id="8_8i2im"] +[ext_resource type="Script" uid="uid://cyvphy8py4ntr" path="res://addons/godot_state_charts/atomic_state.gd" id="10_mvu25"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_tvyy1"] +radius = 6.0 + +[sub_resource type="Resource" id="Resource_mq184"] +resource_name = "Horizontal Input" +script = ExtResource("8_8i2im") +expression = "input_dir.x != 0.0" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[sub_resource type="Resource" id="Resource_nye2q"] +resource_name = "Horizontal Movement" +script = ExtResource("8_8i2im") +expression = "velocity.x != 0.0" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[sub_resource type="Resource" id="Resource_n665q"] +resource_name = "No Horizontal Movement" +script = ExtResource("8_8i2im") +expression = "velocity.x == 0.0" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[sub_resource type="Resource" id="Resource_8c74o"] +resource_name = "No Horizontal Input" +script = ExtResource("8_8i2im") +expression = "input_dir.x == 0.0" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[sub_resource type="Resource" id="Resource_xs4s5"] +resource_name = "Opposite Input" +script = ExtResource("8_8i2im") +expression = "input_dir.x != signf(velocity.x)" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[sub_resource type="Resource" id="Resource_e1cbd"] +resource_name = "Aligned Input" +script = ExtResource("8_8i2im") +expression = "input_dir.x == signf(velocity.x)" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics", "run_animation")] +collision_layer = 16 +collision_mask = 3 +floor_snap_length = 3.0 +script = ExtResource("1_xs4s5") +run_acceleration = 100.0 +max_run_speed = 100.0 +turn_acceleration = 200.0 +stopping_force = 150.0 +state_chart = NodePath("StateChart") +graphics = NodePath("Graphics") +run_animation = NodePath("Graphics/Sprite/Run") + +[node name="CollisionShape" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_tvyy1") +debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42) + +[node name="Graphics" type="Node2D" parent="."] + +[node name="Sprite" type="Sprite2D" parent="Graphics"] +texture = ExtResource("3_trcll") +offset = Vector2(0, -2) +hframes = 4 +vframes = 4 +region_rect = Rect2(0, 0, 64, 64) + +[node name="Idle" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") + +[node name="Bark" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(1, 0) + +[node name="Run" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(0, 2) +frames = 4 +fps = 16.0 +loop = true + +[node name="Jump" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(2, 0) + +[node name="Fall" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(3, 0) + +[node name="StateChart" type="Node" parent="."] +script = ExtResource("5_bcjtl") +track_in_editor = true +initial_expression_properties = { +&"input_dir": Vector2(0, 0), +&"velocity": Vector2(0, 0) +} + +[node name="Root" type="Node" parent="StateChart"] +script = ExtResource("6_jnxnd") +initial_state = NodePath("Grounded") + +[node name="Grounded" type="Node" parent="StateChart/Root"] +editor_description = "Player is standing on a floor." +script = ExtResource("6_jnxnd") +initial_state = NodePath("Standing") + +[node name="Standing" type="Node" parent="StateChart/Root/Grounded"] +editor_description = "Player is standing still or coming to a stop." +script = ExtResource("6_jnxnd") +initial_state = NodePath("Idle") +metadata/_custom_type_script = "uid://b11v7h3ny6kh1" + +[node name="when WalkHeld" type="Node" parent="StateChart/Root/Grounded/Standing"] +editor_description = "Transition to running state if a horizontal direction is being held." +script = ExtResource("7_rgjdc") +to = NodePath("../../Running") +guard = SubResource("Resource_mq184") +delay_in_seconds = "0.0" + +[node name="Idle" type="Node" parent="StateChart/Root/Grounded/Standing"] +editor_description = "Player is stopped, standing still." +script = ExtResource("10_mvu25") + +[node name="when Moving" type="Node" parent="StateChart/Root/Grounded/Standing/Idle"] +editor_description = "Transition to stopping state if the player has horizontal velocity." +script = ExtResource("7_rgjdc") +to = NodePath("../../Stopping") +guard = SubResource("Resource_nye2q") +delay_in_seconds = "0.0" + +[node name="Stopping" type="Node" parent="StateChart/Root/Grounded/Standing"] +editor_description = "Player is slowing to a stop naturally." +script = ExtResource("10_mvu25") + +[node name="when Stopped" type="Node" parent="StateChart/Root/Grounded/Standing/Stopping"] +editor_description = "Transition to idle state when the player has come to a full stop." +script = ExtResource("7_rgjdc") +to = NodePath("../../Idle") +guard = SubResource("Resource_n665q") +delay_in_seconds = "0.0" + +[node name="Running" type="Node" parent="StateChart/Root/Grounded"] +editor_description = "Player is accelerating in the held input direction." +script = ExtResource("10_mvu25") + +[node name="when WalkReleased" type="Node" parent="StateChart/Root/Grounded/Running"] +editor_description = "Transition to standing state if no input direction is held." +script = ExtResource("7_rgjdc") +to = NodePath("../../Standing") +guard = SubResource("Resource_8c74o") +delay_in_seconds = "0.0" + +[node name="when OppositeInput" type="Node" parent="StateChart/Root/Grounded/Running"] +editor_description = "Transition to turning state if the held input dir is opposite the horizontal velocity." +script = ExtResource("7_rgjdc") +to = NodePath("../../Turning") +guard = SubResource("Resource_xs4s5") +delay_in_seconds = "0.0" + +[node name="Turning" type="Node" parent="StateChart/Root/Grounded"] +editor_description = "Player is more quickly accelerating in the held input direction to slow and turn around." +script = ExtResource("10_mvu25") + +[node name="when WalkReleased" type="Node" parent="StateChart/Root/Grounded/Turning"] +editor_description = "Transition to standing state if no input direction is held." +script = ExtResource("7_rgjdc") +to = NodePath("../../Standing") +guard = SubResource("Resource_8c74o") +delay_in_seconds = "0.0" + +[node name="when AlignedInput" type="Node" parent="StateChart/Root/Grounded/Turning"] +editor_description = "Transition to running state when input direction matches horizontal velocity." +script = ExtResource("7_rgjdc") +to = NodePath("../../Running") +guard = SubResource("Resource_e1cbd") +delay_in_seconds = "0.0" + +[node name="Airborne" type="Node" parent="StateChart/Root"] +script = ExtResource("6_jnxnd") +initial_state = NodePath("Falling") + +[node name="Falling" type="Node" parent="StateChart/Root/Airborne"] +script = ExtResource("10_mvu25") + +[node name="Voice" type="AudioStreamPlayer" parent="."] +bus = &"Capri" + +[connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"] +[connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Stopping" to="Graphics/Sprite/Run" method="play"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_scale_run_animation"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_slow_to_stop"] +[connection signal="state_entered" from="StateChart/Root/Grounded/Running" to="Graphics/Sprite/Run" method="play"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_scale_run_animation"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] +[connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Bark" method="play"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Turning" to="." method="_apply_turn_acceleration"] diff --git a/project.godot b/project.godot index 958a0c3..f53d2d3 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Capri" -run/main_scene="res://maps/tutorial.tscn" +run/main_scene="uid://cccb8wltupasj" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" @@ -27,7 +27,7 @@ window/size/viewport_height=216 [editor_plugins] -enabled=PackedStringArray("res://addons/YouCanDoIt/plugin.cfg", "res://addons/godot_state_charts/plugin.cfg") +enabled=PackedStringArray("res://addons/godot_state_charts/plugin.cfg") [file_customization] @@ -44,6 +44,34 @@ folder_colors={ screen_overlay="Autoload that will be rendered over the game viewport at full resolution." +[input] + +move_left={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_right={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_up={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_down={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +jump={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"location":0,"echo":false,"script":null) +] +} + [layer_names] 2d_physics/layer_1="solid" From d7fee943bc60101b8d2adcad3ad7a50ca7aff0cf Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Thu, 6 Mar 2025 08:30:17 -0500 Subject: [PATCH 3/6] proper "skid" turning animation --- assets/textures/player/capri.png | Bin 4558 -> 4529 bytes objects/new_player/new_player.tscn | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index 73426020d343a55d78f2f9a44e5dce240fd60248..f499ac93b8fced1e229de63796876db07089de8b 100644 GIT binary patch delta 553 zcmV+^0@nS`Be5fp;siK4F*T9q9|UrCp8>N80owy4VPrHhF=971Eihs>IW06dFf%PV zF=RO{Ib&uyH(@a{VmV`ClL!SLBw;aSGB#vnW-VefF)}SQGBh?VI5sk4EjKo1G&f~A zVK!knVUtS*CnRJsVL3EpGh!_`H(@a?G&5o{EjchbV=ZH0H8CF*TE@28tv(G&VIhHezEfG-NbmEi_|dWG!K2 zVKFUaFkv!cF)(8^H8^CGRtHf8I65&kv#SSg2n2Qh;SG}=5M6&958*@>c>n+b8A(Jz zR7l6|Q(KaQAP@x10T6P4FtGo?<^U#T{`X^Z|EolW;W5S=*kx50P7g44%NT{+o)(G; z-|&qI+GECB!(voapujZD0mup*CY`olo z2zU(RdN{H+5XgTW0((pg+n5;c*WHxUv~tYsE(f1M-P?76&M!1bu+6&QH~OA^@&+;5 z!N`W$V6>6#ke&v_g;+q_cfy(nw7nOW z0@_W5H4kVz6=DHx|02XZm@XeEECt>D9#vQh19*~;{24h^&Vk5N4>q}t`OsD*bGgh7 resjCzV{J)0gxt{O+Cywv|9u7KSI(;fh00000NkvXXu0mjf$BWcb delta 582 zcmV-M0=fOMBhDj`;si80Ffozl9|U*N=YO*a0owy4Wo0yCF*0UmEiqv?W-T-{H#se0 zWic`>F*7kRW;Qf8Hf1F)%YNG-6^mEjTh}Wi4Z7WHVtmVKO*jVPun*1xE=q zG%+wXFf=nclja4G1T;D@F_U@*Dg-n-Ffo&;28tv!F*G(|GBaW=H90UfEi^b|GA&^- zVKpsbIb~ruH!?OcG&MMrRtHf8G&(Rbv#SSg2n1b2=T(y(5M6&50b-E;dH?_cHc3Q5 zR7l6|R6%mXAPf}d1K50^KzlbN4vO!uSq}>U?|FOWdju61i zA47!2njwnt?bHB4*q^5vV7lt_`Sm-%)XU~X2SxDn)~tuAmxo78=t4$37u=_bal=s1 zoUj>txnHdTboqawt+MWPE`(cHhd4WF)Br`|1>eV4g8P6JxDPNe!4_~_krT`Z7)OEm z01232J~&!nf%u?#!=7M1sBb6*>Vx`*oY;qHeb7#c2Dw~AqyN@fX-cU2d#ykkJY!V- z;kK>Zm2;h;>W|U!0h75WHz!iL8Ij0MiCk_xnsN}a=9b@ z18HTa#G@eXO8t@7uoNAqGPQJBZuEtAQ&v}~^1-^xJy%~ymv8XpgOg9*@s2kB0Qb^f UT3w&f$N&HU07*qoM6N<$f^P-u+yDRo diff --git a/objects/new_player/new_player.tscn b/objects/new_player/new_player.tscn index 0f8c72f..c30ff74 100644 --- a/objects/new_player/new_player.tscn +++ b/objects/new_player/new_player.tscn @@ -81,9 +81,13 @@ script = ExtResource("4_bsdw5") script = ExtResource("4_bsdw5") first_frame = Vector2i(1, 0) +[node name="Skid" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(2, 0) + [node name="Run" type="Node" parent="Graphics/Sprite"] script = ExtResource("4_bsdw5") -first_frame = Vector2i(0, 2) +first_frame = Vector2i(0, 1) frames = 4 fps = 16.0 loop = true @@ -201,5 +205,5 @@ bus = &"Capri" [connection signal="state_entered" from="StateChart/Root/Grounded/Running" to="Graphics/Sprite/Run" method="play"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_scale_run_animation"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] -[connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Bark" method="play"] +[connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Skid" method="play"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Turning" to="." method="_apply_turn_acceleration"] From 749dc520b99e69f65f7bcfaae108198f5bcb746c Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Thu, 6 Mar 2025 09:00:26 -0500 Subject: [PATCH 4/6] slight tweak to bark --- assets/textures/player/capri.png | Bin 4529 -> 4532 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index f499ac93b8fced1e229de63796876db07089de8b..a2fecdce87b5a05b5481d84956ab43066ae79a82 100644 GIT binary patch delta 470 zcmdm}yhVA!LsnBuD^r7s&*WKl9s2%eGbiJ1W);h{WQ!yt10!8a0}~Tn6GL-DU5hj$ zb6s;2qZG@uwA3_X}U>?re?ZHNy+Bs#umwm z=H{uBy;(Js&5TowEsQL5Qw-D6bWIY?O?4B2q;9H_fw`rnNuptrvC-sdtZrPErj`a~ z76#@97L%W`_Cwq@xr$8_%38tJrIKoqoSJHGZl-ILlmar#(p=Zl!X!yI)iTvG$t2a- z%rwnnau|C6M9b#Y?0Fn4@j2@zO_mji<+3(Pe))ozfq_wGa*Kd2BhTbb0%rA+3Y=zf zX$nkohj+-GTiknFfQ@OU;)df}Hnbio*#9oi(pUTVnRi7WB(Lm^6@T%^shQ>W8t%Hq z?{BK-3oMrH$(h0HCVeyR(q;)Q{SHO8Z>$-=3l(qg6Hk)+P-mT}x8Q9^#OH=>!HQxR zzRlh6j4}6p>rx;$@htN#zt#wc+xt0u4f&UyX6N#DEZ^@gI_(g{yeG=_Y*ULBKCNY+ zedkzBhW4bLG0)ic?~MJlaoZAEr@R+MMURej3cLScFs-vnF0eW7zyJiEu6{1-oD!M< D2|1|j delta 467 zcmdm@yis|=LslaTD?`(X&*WK(%H}g}=48Chtdf{wVrZCTZl-IHWM-*rVs2opYiXEb zscV^>W@(;iXq04`oHUt(RbD00FxAK`B_&Na$=J|H*Tl%gOxME9C|TFsEX~9`)iTj6 z(IRoOH>-xSVWOo;igA*z1yH-LiE)yVuBCxxvTkyssiBc+a;j-+ipAt^xs3?$+7~mTr&I*UBoIG7#Jldw+QGm8cg0KU{-JKAe6J` zP9sMJ&*LhKO=bcoWSOdcxNpypcz6Bol*?O+&b-lMpYM40c4^}|eG`ujXLmg?|241n z6Pw|!gD2WXd&Q?Q-STZU< Date: Thu, 6 Mar 2025 09:22:37 -0500 Subject: [PATCH 5/6] create airborne animations --- assets/textures/player/capri.png | Bin 4532 -> 4664 bytes assets/textures/player/capri.xcf | Bin 0 -> 5783 bytes objects/new_player/new_player.tscn | 14 +++++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 assets/textures/player/capri.xcf diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index a2fecdce87b5a05b5481d84956ab43066ae79a82..c2ac482e1f1ff36efadb10c8d9e9b4cf49df7b0c 100644 GIT binary patch delta 702 zcmdm@yhCNeeRfMLBSR}w^NG*oStPY)ec#N>xxmD}9F($L)8 z#LUFfeDX8aUYP49SFx$X*(=z(RFW)Gfi@T#>L!^d8R?psr>5v8CYf65CK{TXnI&18 zrzDzKP7Y)DgK65lnmvz$C3V5E8IxrNV(R%sE&o=vePCcA7~*mK?UdNEW(9#( z$4v|^dI~(>Vhy-AtgL+Ry!-!Jk=BRl2Fqg|o;^vqvQyzhY`dYI zSkHAW{>6)!SeKoWY1q^B`|PPnU$-@$a zJI@xUG#f@Grc9k_aO*_XWaH24o(SBlJnqM|(OzHW&0c}O4ZmNvtZcZka>EbCjlqgy z0@dm|bq;UV8i)&6i;CGRlxZDdO0pMRB=7T>U*uU+o?U;v(iv7p2VFj?^Nr2U_OdCGg!-!A-a{Zo%??>gI>Q%$i(b*bOh z*s4^m%XiA^4pFwfY`)Ov>jLqATO@sVbIi5bd0CkI$IFX82M?yKYMjT;oh!`Mx-~(Z zA&pVXqvHGG?{Z>hT2AGc=d#Wzp$PzV6dKV0 delta 569 zcmdm?vPF5qeRc~gQ%fsTgNe`NS#}-z{$?{L<85XY%d}*RBqIYOT}uNK6I~NSb3eqP$sDZm%1NnaDJDjS#=0pf2IjgZ7O82vNr|Rrx=BgN=H|v0 z$%*FXlf76qmCcM(j4g~TbW;q|(sWG{%}sR^fuwG#k%76TrAeY;lCja`X{@f?W|pRw z24)rp<^~p%pRxABTsOIjO&!i&!PcdcYLT3pYHn_(Ym}4%GSJdo*V4iyNjKFp)iTK> z)!585&0=yGyB|!`=GE+Z94zrU>n2T>6^NNuq{|o?83LX8=f)d zzHeO$=i6#~m1ez|+;wWt~$(699w4*b)E$ diff --git a/assets/textures/player/capri.xcf b/assets/textures/player/capri.xcf new file mode 100644 index 0000000000000000000000000000000000000000..35f1b36eb24a1434773e43502c14de7c85cc4520 GIT binary patch literal 5783 zcmd5=&u<$=6rP=(_1aD=8j=)*5G(BaB5_bJfFAqrB3 z(49J`oDjnO7WHVjvXWbCH7jAQoNJWoW%LObGIDuwF<3GKXr8EIfw{0=s+M!rR=7$t zKJWf?yK}Er4%*FHxOyr(U8$}#Yt2?Lt*czCdb1Q1^rv_V!#DRCE(ZF;;f?lMX(en_ zgW_4V?hUl!MsB?kc7m|6a;w~?N3&9Cmpeg$_6gmngT`F*c;a`|%bn6{sZ(M>LcG^qj)^e%7Rx3}=&j$F+&A{|v7kXbURVU|*g|kCU^)o&!H>#amlk;a! zKa2IJ;p#IPf6@xejZUe94Zuo<%zUMcV_&E3H5|(1{5wPJmz$N&-BJr1vQ!Eio&3ia zuLfuG#r)et{BHCgghdr+i!;T-5SP#Xjmy%lW~Z57Byg7jK&lMt$K6e1kb4?8j{onOH|9CKLM02|b(8gIK387sPp3 zjzO$`JfS}aozJtyheA8f|7NVC5^qok*Kw_{Cv?kf1@t9~x14C$A5X?Z@tUUA-*$}s zU)laKwJRK{b{&~jkt0RqpcbwZiL}}j(s5mM`sy*r)>SST*H>HAp{8NzIlk(`OiHl> zLr*=zpcG2E!c}^rZ8q?UXU*VwQeygyk`hl%D@SZ$0TR3D#Z##+CWQZ(a3TrGVmq?J zi_*f6e390YLhXqR1j`mOQW$r{P9(IJK`Voiv~aPFF05S44*^#CHBEy|k7={P0SqU722^|kk zp4L+8A$&B$SS(=%;r7V}I68=Ix(*(f!r~r7LGlA})dQ{pFq5pYWCuy6f}|lX>dJZp)sdnbu7~S8EP`^JpkGFQ>+8MW z9@EW8KY{P>3(SwbV13+PJWBVpX&rI^A4H2CefklCkBwU|#(ldEVhZ8K*kVFi-zbBV zHPNdV)EK^!#u)^;INpg=BH*R^anQP?2Zjkq2a_kGWWveEqm6+HnCV^s9dy8z7!0N< zjr*keK&0g@V%P=vZQ#@~*tiks4%pKeBtkK*6G3{wb->IeeNO!()oa|kbE#mfIJ+bFKb3U(RNboG97q?D+>c&+?YJ%6W(dG zcyba{!x?dfd6jVyF*|IrNhUQ(CK}`ssd(|pJ=$G6X@0On7%@A(HzAo$Bqr%te<@B< zOxj@+7n8K4<8*|yzyv0x>49S=nelpk95cc`+A_)M_w^GV+y8U|WP51wbXsJRBx}QQ zLtLirr%+i$MJ8Pw<@!g^9?`muloI2P?#E&46pQr;lCdl#qx}y`yDpV#HD39n6iK&}~lDQFo%+r}Rr{g{cXbx_RI3A#@0;qBpSJ?7ouRB#$i z+=BhmbH+$Y3ULxKG8Kb~z{=>*X>xP@s$};-zqGx-USH!r93^mYfdS;O;CL6li87Xa z5wt%(4w7Sh0kp-Ap*=QdJCi}u2E-w+Z6+QtOc_+{d2LGslLVvVkadvk5x7pvCF1Kg zFaS`2p@}TKD}u7Yq+nBG5j~38A6eTSf|B7cab%etor~GJi!=hzLb2OJ+@wDW+im=- z$NqRLj}(Lgtc!A32)za0M49*?(Xjgv|L%$EK4a*b_}upU;1Ad3xjAYF%wU)W9D+og zX9qrEe!*m3I-6{PQ-oBTc!FjcDK^okIIeVR#d(;G@ABLM3yd+GKY$=7#{_J<&O_bi z8=yqQ28ofWv?~S>v|Yx2;dpo?s7h^tr_hAiU+BghL=-3k@FOWIjW*1rNy$|UI&U}8 gm&j9y%BJ@42f*>3MB*fpbHDfQmleQN6ulz;0kleTJOBUy literal 0 HcmV?d00001 diff --git a/objects/new_player/new_player.tscn b/objects/new_player/new_player.tscn index c30ff74..8ffa2e7 100644 --- a/objects/new_player/new_player.tscn +++ b/objects/new_player/new_player.tscn @@ -92,13 +92,17 @@ frames = 4 fps = 16.0 loop = true -[node name="Jump" type="Node" parent="Graphics/Sprite"] -script = ExtResource("4_bsdw5") -first_frame = Vector2i(2, 0) - [node name="Fall" type="Node" parent="Graphics/Sprite"] script = ExtResource("4_bsdw5") -first_frame = Vector2i(3, 0) +first_frame = Vector2i(0, 2) + +[node name="Jump" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(1, 2) + +[node name="Missile" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(2, 2) [node name="StateChart" type="Node" parent="."] script = ExtResource("5_bcjtl") From a44bb1c14ac06e8ad8cacc88adc406baa882514a Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Thu, 6 Mar 2025 11:58:42 -0500 Subject: [PATCH 6/6] jumping around --- objects/new_player/new_player.gd | 28 +++++++++- objects/new_player/new_player.tscn | 85 ++++++++++++++++++++++++++---- 2 files changed, 101 insertions(+), 12 deletions(-) diff --git a/objects/new_player/new_player.gd b/objects/new_player/new_player.gd index 24d731c..96d4167 100644 --- a/objects/new_player/new_player.gd +++ b/objects/new_player/new_player.gd @@ -8,6 +8,10 @@ extends CharacterBody2D @export var turn_acceleration: float @export var stopping_force: float +@export_group("Air Movement") +@export var gravity: float +@export var jump_power: float + @export_group("Internal References") @export var state_chart: StateChart @export var graphics: Node2D @@ -26,15 +30,21 @@ func _physics_process(delta: float) -> void: if velocity.x != 0.0: graphics.scale.x = signf(velocity.x) + state_chart.set_expression_property(&"on_floor", is_on_floor()) + input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down") +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed(&"jump"): + state_chart.send_event(&"jump_pressed") + + #region Idle func _slow_to_stop(delta: float) -> void: velocity.x = move_toward(velocity.x, 0.0, stopping_force * delta) #endregion - #region Running func _apply_run_acceleration(delta: float) -> void: if absf(velocity.x) < max_run_speed: @@ -49,3 +59,19 @@ func _scale_run_animation(delta:float) -> void: func _apply_turn_acceleration(delta: float) -> void: velocity.x += input_dir.x * turn_acceleration * delta #endregion + + +#region Falling +func _apply_gravity(delta: float) -> void: + velocity.y += gravity * delta +#endregion + + +#region Jumping +func _start_jump() -> void: + velocity.y = -jump_power +#endregion + + +#region Missile +#endregion diff --git a/objects/new_player/new_player.tscn b/objects/new_player/new_player.tscn index 8ffa2e7..582d1f7 100644 --- a/objects/new_player/new_player.tscn +++ b/objects/new_player/new_player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://bwtpsjpe2lf7l"] +[gd_scene load_steps=19 format=3 uid="uid://bwtpsjpe2lf7l"] [ext_resource type="Script" uid="uid://dhyi4yn0xleoy" path="res://objects/new_player/new_player.gd" id="1_xs4s5"] [ext_resource type="Texture2D" uid="uid://c71nqfyw4a3v4" path="res://assets/textures/player/capri.png" id="3_trcll"] @@ -12,6 +12,12 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_tvyy1"] radius = 6.0 +[sub_resource type="Resource" id="Resource_sfpnl"] +resource_name = "Not On Floor" +script = ExtResource("8_8i2im") +expression = "not on_floor" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + [sub_resource type="Resource" id="Resource_mq184"] resource_name = "Horizontal Input" script = ExtResource("8_8i2im") @@ -48,15 +54,29 @@ script = ExtResource("8_8i2im") expression = "input_dir.x == signf(velocity.x)" metadata/_custom_type_script = "uid://b6u7unac5srh0" +[sub_resource type="Resource" id="Resource_163ft"] +resource_name = "On Floor" +script = ExtResource("8_8i2im") +expression = "on_floor" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + +[sub_resource type="Resource" id="Resource_whx0j"] +resource_name = "Falling Down" +script = ExtResource("8_8i2im") +expression = "velocity.y > 0.0" +metadata/_custom_type_script = "uid://b6u7unac5srh0" + [node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics", "run_animation")] collision_layer = 16 collision_mask = 3 floor_snap_length = 3.0 script = ExtResource("1_xs4s5") -run_acceleration = 100.0 +run_acceleration = 150.0 max_run_speed = 100.0 -turn_acceleration = 200.0 -stopping_force = 150.0 +turn_acceleration = 250.0 +stopping_force = 200.0 +gravity = 450.0 +jump_power = 180.0 state_chart = NodePath("StateChart") graphics = NodePath("Graphics") run_animation = NodePath("Graphics/Sprite/Run") @@ -109,6 +129,7 @@ script = ExtResource("5_bcjtl") track_in_editor = true initial_expression_properties = { &"input_dir": Vector2(0, 0), +&"on_floor": false, &"velocity": Vector2(0, 0) } @@ -121,13 +142,26 @@ editor_description = "Player is standing on a floor." script = ExtResource("6_jnxnd") initial_state = NodePath("Standing") +[node name="if NotOnFloor" type="Node" parent="StateChart/Root/Grounded"] +editor_description = "Transition to falling state if not touching a floor." +script = ExtResource("7_rgjdc") +to = NodePath("../../Airborne/Falling") +guard = SubResource("Resource_sfpnl") +delay_in_seconds = "0.0" + +[node name="on JumpPressed" type="Node" parent="StateChart/Root/Grounded"] +script = ExtResource("7_rgjdc") +to = NodePath("../../Airborne/Jumping") +event = &"jump_pressed" +delay_in_seconds = "0.0" + [node name="Standing" type="Node" parent="StateChart/Root/Grounded"] editor_description = "Player is standing still or coming to a stop." script = ExtResource("6_jnxnd") initial_state = NodePath("Idle") metadata/_custom_type_script = "uid://b11v7h3ny6kh1" -[node name="when WalkHeld" type="Node" parent="StateChart/Root/Grounded/Standing"] +[node name="if WalkHeld" type="Node" parent="StateChart/Root/Grounded/Standing"] editor_description = "Transition to running state if a horizontal direction is being held." script = ExtResource("7_rgjdc") to = NodePath("../../Running") @@ -138,7 +172,7 @@ delay_in_seconds = "0.0" editor_description = "Player is stopped, standing still." script = ExtResource("10_mvu25") -[node name="when Moving" type="Node" parent="StateChart/Root/Grounded/Standing/Idle"] +[node name="if Moving" type="Node" parent="StateChart/Root/Grounded/Standing/Idle"] editor_description = "Transition to stopping state if the player has horizontal velocity." script = ExtResource("7_rgjdc") to = NodePath("../../Stopping") @@ -149,7 +183,7 @@ delay_in_seconds = "0.0" editor_description = "Player is slowing to a stop naturally." script = ExtResource("10_mvu25") -[node name="when Stopped" type="Node" parent="StateChart/Root/Grounded/Standing/Stopping"] +[node name="if Stopped" type="Node" parent="StateChart/Root/Grounded/Standing/Stopping"] editor_description = "Transition to idle state when the player has come to a full stop." script = ExtResource("7_rgjdc") to = NodePath("../../Idle") @@ -160,14 +194,14 @@ delay_in_seconds = "0.0" editor_description = "Player is accelerating in the held input direction." script = ExtResource("10_mvu25") -[node name="when WalkReleased" type="Node" parent="StateChart/Root/Grounded/Running"] +[node name="if WalkReleased" type="Node" parent="StateChart/Root/Grounded/Running"] editor_description = "Transition to standing state if no input direction is held." script = ExtResource("7_rgjdc") to = NodePath("../../Standing") guard = SubResource("Resource_8c74o") delay_in_seconds = "0.0" -[node name="when OppositeInput" type="Node" parent="StateChart/Root/Grounded/Running"] +[node name="if OppositeInput" type="Node" parent="StateChart/Root/Grounded/Running"] editor_description = "Transition to turning state if the held input dir is opposite the horizontal velocity." script = ExtResource("7_rgjdc") to = NodePath("../../Turning") @@ -178,14 +212,14 @@ delay_in_seconds = "0.0" editor_description = "Player is more quickly accelerating in the held input direction to slow and turn around." script = ExtResource("10_mvu25") -[node name="when WalkReleased" type="Node" parent="StateChart/Root/Grounded/Turning"] +[node name="if WalkReleased" type="Node" parent="StateChart/Root/Grounded/Turning"] editor_description = "Transition to standing state if no input direction is held." script = ExtResource("7_rgjdc") to = NodePath("../../Standing") guard = SubResource("Resource_8c74o") delay_in_seconds = "0.0" -[node name="when AlignedInput" type="Node" parent="StateChart/Root/Grounded/Turning"] +[node name="if AlignedInput" type="Node" parent="StateChart/Root/Grounded/Turning"] editor_description = "Transition to running state when input direction matches horizontal velocity." script = ExtResource("7_rgjdc") to = NodePath("../../Running") @@ -193,10 +227,34 @@ guard = SubResource("Resource_e1cbd") delay_in_seconds = "0.0" [node name="Airborne" type="Node" parent="StateChart/Root"] +editor_description = "Player is in the air." script = ExtResource("6_jnxnd") initial_state = NodePath("Falling") +[node name="if OnFloor" type="Node" parent="StateChart/Root/Airborne"] +editor_description = "Transition to grounded state if touching a floor." +script = ExtResource("7_rgjdc") +to = NodePath("../../Grounded") +guard = SubResource("Resource_163ft") +delay_in_seconds = "0.0" + [node name="Falling" type="Node" parent="StateChart/Root/Airborne"] +editor_description = "Player is falling down." +script = ExtResource("10_mvu25") + +[node name="Jumping" type="Node" parent="StateChart/Root/Airborne"] +editor_description = "Player has jumped and is rising." +script = ExtResource("10_mvu25") + +[node name="if DownVelocity" type="Node" parent="StateChart/Root/Airborne/Jumping"] +editor_description = "Transition to the falling state if moving downwards." +script = ExtResource("7_rgjdc") +to = NodePath("../../Falling") +guard = SubResource("Resource_whx0j") +delay_in_seconds = "0.0" + +[node name="Missile" type="Node" parent="StateChart/Root/Airborne"] +editor_description = "Player is hurtling through the air and ricocheting off of surfaces." script = ExtResource("10_mvu25") [node name="Voice" type="AudioStreamPlayer" parent="."] @@ -211,3 +269,8 @@ bus = &"Capri" [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] [connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Skid" method="play"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Turning" to="." method="_apply_turn_acceleration"] +[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_apply_gravity"] +[connection signal="state_entered" from="StateChart/Root/Airborne/Falling" to="Graphics/Sprite/Fall" method="play"] +[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="." method="_start_jump"] +[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Graphics/Sprite/Jump" method="play"] +[connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Graphics/Sprite/Missile" method="play"]