From 7a2842b5eed1bb35299e62584546980132c8cbb0 Mon Sep 17 00:00:00 2001 From: Nitsud Yarg Date: Fri, 12 Jul 2024 10:49:54 -0700 Subject: [PATCH] Platform actor works when not being stood on. --- assets/elevator.png | Bin 0 -> 1752 bytes assets/elevator.png.import | 35 ++++++++ .../Platform/PlatformVMove/PlatformVMove.tscn | 77 +++++++++++++++--- .../Platform/PlatformVMove/states2/idle.gd | 16 ++-- .../Platform/PlatformVMove/states2/move.gd | 32 +++++--- src/Levels/Level.tscn | 6 +- 6 files changed, 134 insertions(+), 32 deletions(-) create mode 100644 assets/elevator.png create mode 100644 assets/elevator.png.import diff --git a/assets/elevator.png b/assets/elevator.png new file mode 100644 index 0000000000000000000000000000000000000000..e175bb87e18c9bb8d0c0dbf012dc42d4ce0d0030 GIT binary patch literal 1752 zcmV;}1}FK6P)Px#Fi=cXMNlXRP*6}{U|4u?U}$h~czAG#04T^92>5tV9dNyfn23mon5eLz__(OR zz_{q(;6f0c0{{R35Oh*bQ~&?}|NsC0|Nj90|NsC0|6dpQqyPX0I!Q!9RCt{2nt_(1 zDh!4blm0It}+2-ud%n|uWV?aoM`1$7z{@Q`Rw=e{7(h?)woeBXE z(VQ^EHM|fi{{%F(C96*v6AVt?mO=%NtFhhqOEwN&XWy`{8>D|{jXtqrs1gE1ii>Z0 z*T^M`tV=OE=t`nP_W%Ev2kU3z3V89?w5ZWlv&Qy*;1%;2ymJubRT11 z8({@1eR1n-0aTp`0oH|Yw1iK9rWS5a^NwAf66Xcdz?P5xy`mGTL zWX4vo%k@;KG_cCVa1&DoRd_HuHf^&Lcqr24fWPK6~GjI6W#vUS$Q_uX@|tg*7lY@r5!dDo8o2a%w*)UEEvfw(60wG1juaiw*o>nTKTt<L6-# z!);wgQV%pec`+=XSRqspYE9Ikr}c$Xg?3%S9jj=1xvQh6(#@QX#xSCuy)A{xMS2-PjG zOx07G?><;FJ6j0VX94yc6W2fkbc~hQRvRwJp-YaP20H0e^YiI3d|qWxrFKZoTu`K? zf>Wvoe;l_w#X#ni%r)T2r8PL{In8)!A}+ZzSNRH|&WGjsI~L6@0dqw{&)ocn8Kxqn znR}pzERVGXQ1!6P#Wby@nhDDpCVi(9!h2(@W{r9kk9RE0x$Aaxj=xwS8m_!7!|oljv^ z;N1Fq;Fr|KJ+J2DR5~0#4^!jcUGpX?0Cy<$fd^n0KoM3CXx}2#MhXOuB;)_LkJdSP&YnY|(h!*Sk`82b;pW zG=tf0-kJJh$aG}ib@hJKBZI=q&iHvl>W4-y*}ft8hTt25pJfQvOG&OJMz}i_0^se{ z!q-r>a8`s`_!_Fzp9)b6UqjUrToG#FYp7aGEJ7`O4RsDd0czoEs5%j_1hw!rR0%;L zYT;|Bpl{j|)WX+LA=qu)UM+kL)o+c;Pzzr}oxfJ~H-0t9vwbzlUk&nCgZxiwkbPF2 z()A{sy*X7wAhKRzzoqNNm|VCBst>^|>qU4&*Nbtva2Zqy!9v!Hxw>9V$b}1`g2pwJ z^=9gN6LR5FsPGe!_2%h%6LR5VsPMCu^_o0guZhZq%b{`zHnQGqUGG*dTn<&TU?uCd zIl5jOmkXCeb^o@q-uk$%w@%1~%b`m7bR+A1L)W{O3l~Gx*sf%~85-oIT=)<*r9nPL zO=^&%RIL}RWxZJ%g#Q(yJJmZUD{WJ ue9qPTQI8A?D?8)o4XGa*xn%o>;O9RCeF&%Q@=s&{0000 void: .enter() # parent.set_hurtbox(true) - move_component.velocity.x = 0 if debug_state: print(owner.name, " Move Component: ", move_component.desired_movement_vector.x) + state_timeout.start() + +func process_frame(delta): + if state_timeout.time_left == 0: + return move_state + return null func process_physics(delta: float) -> State: @@ -20,11 +23,4 @@ func process_physics(delta: float) -> State: # parent.velocity.x = move_component.desired_movement_vector.x * move_speed # parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1)) - move_actor_as_desired(delta) - - if move_component.velocity.x != 0.0: - return move_state - - if !parent.is_on_floor(): - return fall_state return null diff --git a/src/Actors/Platform/PlatformVMove/states2/move.gd b/src/Actors/Platform/PlatformVMove/states2/move.gd index f93dab5..4113da8 100644 --- a/src/Actors/Platform/PlatformVMove/states2/move.gd +++ b/src/Actors/Platform/PlatformVMove/states2/move.gd @@ -1,21 +1,31 @@ extends StateAnimatedActor -export (NodePath) var fall_node export (NodePath) var idle_node -onready var fall_state: State = get_node(fall_node) onready var idle_state: State = get_node(idle_node) +var flip_flop:bool = true + +func enter() -> void: + .enter() +# parent.set_hurtbox(true) + if debug_state: + print(owner.name, " Move Component: ", move_component.desired_movement_vector.x) + state_timeout.start() + + func process_physics(delta: float) -> State: - move_actor_as_desired(delta) - - if move_component.velocity.x == 0.0: - return idle_state - - #Flip the character before tha actual move maybe. - parent.transform.x.x = move_component.get_movement_direction() + if state_timeout.time_left == 0: + if flip_flop: + move_component.velocity.y = move_speed + flip_flop = false + return idle_state + else: + move_component.velocity.y = move_speed * - 1 + flip_flop = true + return idle_state + + move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1)) - if !parent.is_on_floor(): - return fall_state return null diff --git a/src/Levels/Level.tscn b/src/Levels/Level.tscn index f5a1a46..4c58b92 100644 --- a/src/Levels/Level.tscn +++ b/src/Levels/Level.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=17 format=2] +[gd_scene load_steps=18 format=2] +[ext_resource path="res://src/Actors/Platform/PlatformVMove/PlatformVMove.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/Tiles/Assets/Demo TileSet.tres" type="TileSet" id=2] [ext_resource path="res://assets/Backgrounds/bgmuck.png" type="Texture" id=3] [ext_resource path="res://src/Interactables/Chest.tscn" type="PackedScene" id=4] @@ -174,3 +175,6 @@ collision_mask = 0 modulate = Color( 0.360784, 0.0901961, 0.0901961, 1 ) position = Vector2( 441, 283 ) shape = SubResource( 6 ) + +[node name="PlatformVMove" parent="." instance=ExtResource( 1 )] +position = Vector2( 359, 319 )