Detector raycasts now scene unique.

This commit is contained in:
Dustin 2025-04-21 23:58:14 -07:00
parent f87eb297ba
commit b5b320f4a7
2 changed files with 12 additions and 9 deletions

View File

@ -156,7 +156,7 @@ func _state_process_physics_idle():
#parent_request_state_change.call_func('attack_sword')
attack_secondary()
if $"../LadderDetector".is_colliding() and _wants_climb == true:
if $"%LadderDetector".is_colliding() and _wants_climb == true:
request_state_change.call_func('climb')
func attack_primary():
@ -246,7 +246,7 @@ func _state_process_physics_enter_right():
move_actor_as_desired(parent.transform.x.x)
func _state_process_physics_land():
$"../LedgeDetector".set_enabled(true)
$"%LedgeDetector".set_enabled(true)
if current_state.animation_finished == true:
request_state_change.call_func('idle')
@ -275,10 +275,10 @@ func _state_process_physics_hurt():
func _state_process_physics_fall():
flip_sprite_to_movement_direction()
if $"../LedgeDetector".is_colliding() and !$"../WallDetector".is_colliding():
if $"%LedgeDetector".is_colliding() and !$"%WallDetector".is_colliding():
#print("it touched me!")
if debug_component:
UiManager.debug_text = (str($"../LedgeDetector".get_collision_point()))
UiManager.debug_text = (str($"%LedgeDetector".get_collision_point()))
request_state_change.call_func('ledge_grab')
if parent.is_on_floor():
@ -317,10 +317,10 @@ func _state_process_physics_move():
move_actor_as_desired()
func get_climb_shape_location() -> Vector2:
if $"../LadderDetector".is_colliding():
var point: Vector2 = $"../LadderDetector".get_collision_point()
var shape_id = $"../LadderDetector".get_collider_shape()
var object = $"../LadderDetector".get_collider()
if $"%LadderDetector".is_colliding():
var point: Vector2 = $"%LadderDetector".get_collision_point()
var shape_id = $"%LadderDetector".get_collider_shape()
var object = $"%LadderDetector".get_collider()
# This appears to get the shapes location!
var area = Physics2DServer.area_get_transform(object)
@ -360,7 +360,7 @@ func _state_process_physics_climb():
func _state_process_physics_ledge_grab():
if debug_component:
UiManager.debug_text = (str(velocity))
$"../LedgeDetector".set_enabled(false)
$"%LedgeDetector".set_enabled(false)
if _wants_jump:
request_state_change.call_func('ledge_climb')

View File

@ -110,18 +110,21 @@ __meta__ = {
script = ExtResource( 6 )
[node name="LedgeDetector" type="RayCast2D" parent="." index="3"]
unique_name_in_owner = true
modulate = Color( 0, 1, 0, 1 )
position = Vector2( 8, -10 )
enabled = true
cast_to = Vector2( 1.36422e-12, -1 )
[node name="WallDetector" type="RayCast2D" parent="." index="4"]
unique_name_in_owner = true
modulate = Color( 0, 1, 0, 1 )
position = Vector2( 6, -16 )
enabled = true
cast_to = Vector2( 4, 4 )
[node name="LadderDetector" type="RayCast2D" parent="." index="5"]
unique_name_in_owner = true
modulate = Color( 0, 1, 0, 1 )
enabled = true
cast_to = Vector2( 1.36422e-12, 20 )