Yay! Ledge climbing!

This commit is contained in:
Dustin 2025-03-25 21:56:02 -07:00
parent 1d469f7462
commit 6bd4d302e0
4 changed files with 70 additions and 17 deletions

View File

@ -161,6 +161,7 @@ func _state_process_physics_roll():
func _state_process_physics_land(): func _state_process_physics_land():
$"../LedgeDetector".set_enabled(true)
if current_state.animation_finished == true: if current_state.animation_finished == true:
request_state_change.call_func('idle') request_state_change.call_func('idle')
@ -232,10 +233,40 @@ func _state_process_physics_move():
func _state_process_physics_ledge_grab(): func _state_process_physics_ledge_grab():
UiManager.debug_text = (str(velocity)) UiManager.debug_text = (str(velocity))
$"../LedgeDetector".set_enabled(false)
if _wants_jump:
request_state_change.call_func('ledge_climb')
if _wants_crouch: if _wants_crouch:
request_state_change.call_func('fall') request_state_change.call_func('fall')
func _state_process_physics_ledge_climb():
# UiManager.debug_text = (str(velocity))
# $"../LedgeDetector".set_enabled(false)
UiManager.debug_text = (str(parent.is_on_floor()) +
str(parent.is_on_wall()) + ")\nV:" + str(velocity))
if current_state.animation_finished == true:
request_state_change.call_func('land')
return
if parent.is_on_wall() == true:
#velocity = parent.move_and_slide(Vector2(10.0,-60.0),Vector2.UP)
parent.move_and_slide(Vector2(10.0,-100.0),Vector2.UP)
else: #parent.is_on_floor() == true:
#velocity = parent.move_and_slide(Vector2(10.0,10.0),Vector2.UP)
parent.move_and_slide(Vector2(60.0,10.0),Vector2.UP)
#velocity = parent.move_and_slide(Vector2(60.0,-60.0),Vector2.UP)
# if parent.is_on_wall() != true:
# #modifier.reference()
# #idle_state.modifier = landing_modifier
# request_state_change.call_func('land')
# return
func _state_process_physics_crouch(): func _state_process_physics_crouch():
# flip sprite in direction # flip sprite in direction
flip_sprite_to_movement_direction() flip_sprite_to_movement_direction()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=2] [gd_scene load_steps=24 format=2]
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2] [ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
@ -18,6 +18,8 @@
[ext_resource path="res://lib/components/Hurtbox_Component.tscn" type="PackedScene" id=16] [ext_resource path="res://lib/components/Hurtbox_Component.tscn" type="PackedScene" id=16]
[ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=17] [ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=17]
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=18] [ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=18]
[ext_resource path="res://src/actors/players/playerE/states/ledge_grab.tres" type="Resource" id=19]
[ext_resource path="res://src/actors/players/playerE/states/ledge_climb.tres" type="Resource" id=20]
[sub_resource type="Resource" id=3] [sub_resource type="Resource" id=3]
resource_local_to_scene = true resource_local_to_scene = true
@ -33,20 +35,6 @@ horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0 jerk_factor = 0.0
animation_sequence = [ "hurt" ] animation_sequence = [ "hurt" ]
[sub_resource type="Resource" id=4]
resource_local_to_scene = true
resource_name = "ledge_grab"
script = ExtResource( 18 )
debug_state = false
timeout_seconds = 0.0
name = "ledge_grab"
horizontal_speed = 1.36422e-12
horizontal_acceleration = 0.0
horizontal_speed_offset = 0.0
horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0
animation_sequence = [ "ledge-grab" ]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 14 ) extents = Vector2( 7, 14 )
@ -60,7 +48,7 @@ actor_type = "Player"
[node name="Movement_StateMachine" parent="." index="0"] [node name="Movement_StateMachine" parent="." index="0"]
debug_state_machine = true debug_state_machine = true
starting_state_name = "idle" starting_state_name = "idle"
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ), SubResource( 4 ) ] states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ), ExtResource( 19 ), ExtResource( 20 ) ]
[node name="AnimatedSprite_StateReceiver" parent="." index="1"] [node name="AnimatedSprite_StateReceiver" parent="." index="1"]
frames = ExtResource( 2 ) frames = ExtResource( 2 )
@ -85,7 +73,7 @@ script = ExtResource( 6 )
[node name="LedgeDetector" type="RayCast2D" parent="." index="3"] [node name="LedgeDetector" type="RayCast2D" parent="." index="3"]
modulate = Color( 0, 1, 0, 1 ) modulate = Color( 0, 1, 0, 1 )
position = Vector2( 8, -11 ) position = Vector2( 8, 5 )
enabled = true enabled = true
cast_to = Vector2( 1.36422e-12, 1 ) cast_to = Vector2( 1.36422e-12, 1 )

View File

@ -0,0 +1,17 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
[resource]
resource_local_to_scene = true
resource_name = "ledge_climb"
script = ExtResource( 1 )
debug_state = false
timeout_seconds = 0.0
name = "ledge_climb"
horizontal_speed = 1.36422e-12
horizontal_acceleration = 0.0
horizontal_speed_offset = 0.0
horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0
animation_sequence = [ "ledge-climb" ]

View File

@ -0,0 +1,17 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
[resource]
resource_local_to_scene = true
resource_name = "ledge_grab"
script = ExtResource( 1 )
debug_state = false
timeout_seconds = 0.0
name = "ledge_grab"
horizontal_speed = 1.36422e-12
horizontal_acceleration = 0.0
horizontal_speed_offset = 0.0
horizontal_speed_offset_acceleration = 0.0
jerk_factor = 0.0
animation_sequence = [ "ledge-grab" ]