Added high wall rays

This commit is contained in:
2026-02-13 00:55:15 +03:00
parent 0dff01da11
commit ebc0133a82
16 changed files with 65 additions and 31 deletions
+2
View File
@@ -17,3 +17,5 @@ mono_crash.*.json
export
*.tmp
+5 -2
View File
@@ -15,8 +15,11 @@ var target_x := 0.0
@onready var sprite : AnimatedSprite2D = $CultistSprite
@onready var left_wall_ray : RayCast2D = $%LeftWallRay
@onready var right_wall_ray : RayCast2D = $%RightWallRay
@onready var left_wall_high_ray : RayCast2D = $WallCheckHigh/LeftWallRay
@onready var right_wall_high_ray : RayCast2D = $WallCheckHigh/RightWallRay
@onready var left_wall_low_ray : RayCast2D = $WallCheckLow/LeftWallRay
@onready var right_wall_low_ray : RayCast2D = $WallCheckLow/RightWallRay
@onready var left_player_close_ray : RayCast2D = $%LeftPlayerCloseRay
@onready var right_player_close_ray : RayCast2D = $%RightPlayerCloseRay
+16 -9
View File
@@ -34,19 +34,26 @@ script = ExtResource("1_2wrno")
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_mocsw")
[node name="WallCheck" type="Node2D" parent="." unique_id=782156094]
position = Vector2(0, 9)
[node name="WallCheckHigh" type="Node2D" parent="." unique_id=1697845810]
position = Vector2(0, -8)
[node name="LeftWallRay" type="RayCast2D" parent="WallCheck" unique_id=521416854]
unique_name_in_owner = true
[node name="LeftWallRay" type="RayCast2D" parent="WallCheckHigh" unique_id=1026693538]
target_position = Vector2(-16, 0)
[node name="RightWallRay" type="RayCast2D" parent="WallCheck" unique_id=1457669135]
unique_name_in_owner = true
[node name="RightWallRay" type="RayCast2D" parent="WallCheckHigh" unique_id=1129233918]
target_position = Vector2(16, 0)
[node name="WallCheckLow" type="Node2D" parent="." unique_id=782156094]
position = Vector2(0, 9)
[node name="LeftWallRay" type="RayCast2D" parent="WallCheckLow" unique_id=521416854]
target_position = Vector2(-16, 0)
[node name="RightWallRay" type="RayCast2D" parent="WallCheckLow" unique_id=1457669135]
target_position = Vector2(16, 0)
[node name="PlayerCloseCheck" type="Node2D" parent="." unique_id=1593775088]
position = Vector2(0, 9)
position = Vector2(0, -8)
[node name="LeftPlayerCloseRay" type="RayCast2D" parent="PlayerCloseCheck" unique_id=947570027]
unique_name_in_owner = true
@@ -59,7 +66,7 @@ target_position = Vector2(48, 0)
collision_mask = 0
[node name="PlayerDistantCheck" type="Node2D" parent="." unique_id=1597489123]
position = Vector2(0, 9)
position = Vector2(0, -8)
[node name="LeftPlayerDistantRay" type="RayCast2D" parent="PlayerDistantCheck" unique_id=1491085518]
unique_name_in_owner = true
@@ -132,7 +139,7 @@ cultist = NodePath("../..")
[node name="ChaseRightState" parent="CultistStateMachine" unique_id=383038915 node_paths=PackedStringArray("look_around_state", "jump_state", "fall_state", "cultist") instance=ExtResource("5_tu2pi")]
script = ExtResource("14_cqp7f")
look_around_state = NodePath("../LookAroundState")
jump_state = NodePath(".")
jump_state = NodePath("../JumpRightState")
fall_state = NodePath("../FallState")
cultist = NodePath("../..")
+1 -1
View File
@@ -391,5 +391,5 @@ animations = [{
[node name="CultistSprite" type="AnimatedSprite2D" unique_id=351120861]
material = SubResource("ShaderMaterial_vecdo")
sprite_frames = SubResource("SpriteFrames_2wrno")
animation = &"fall_left"
animation = &"idle"
script = ExtResource("3_ef0vi")
@@ -3,7 +3,8 @@ extends CultistChaseState
func init() -> void:
_direction = DIRECTION_LEFT
_wall_ray_cast = cultist.left_wall_ray
_wall_high_ray_cast = cultist.left_wall_high_ray
_wall_low_ray_cast = cultist.left_wall_low_ray
_player_ray_cast = cultist.left_player_distant_ray
@@ -3,7 +3,8 @@ extends CultistChaseState
func init() -> void:
_direction = DIRECTION_RIGHT
_wall_ray_cast = cultist.right_wall_ray
_wall_high_ray_cast = cultist.right_wall_high_ray
_wall_low_ray_cast = cultist.right_wall_low_ray
_player_ray_cast = cultist.right_player_distant_ray
@@ -15,9 +15,9 @@ func physics_process(delta: float) -> void:
if player != null:
cultist.target_x = player.position.x
if _is_target_reached():
if _is_target_reached() or _wall_high_ray_cast.is_colliding():
switch_state.emit(look_around_state)
elif _wall_ray_cast.is_colliding():
elif _wall_low_ray_cast.is_colliding():
switch_state.emit(jump_state)
else:
cultist.update_x_velocity(_direction, cultist.MAX_CHASE_SPEED, delta)
@@ -12,7 +12,7 @@ var state_by_ray_cast : Dictionary[RayCast2D, CultistState]
func enter() -> void:
cultist.sprite.animation_finished.connect(_on_animation_finished, CONNECT_ONE_SHOT)
cultist.sprite.animation_finished.connect(_on_animation_finished)
cultist.sprite.play(CultistSprite.LOOK_AROUND_ANIMATIONS.pick_random())
cultist.velocity = Vector2.ZERO
cultist._set_ray_cast_enable(cultist.left_player_close_ray, true)
@@ -36,6 +36,7 @@ func physics_process(_delta: float) -> void:
func exit() -> void:
cultist.sprite.animation_finished.disconnect(_on_animation_finished)
cultist._set_ray_cast_enable(cultist.left_player_close_ray, false)
cultist._set_ray_cast_enable(cultist.right_player_close_ray, false)
@@ -9,7 +9,9 @@ extends CultistState
@warning_ignore("unused_private_class_variable")
var _direction := 0
@warning_ignore("unused_private_class_variable")
var _wall_ray_cast : RayCast2D
var _wall_high_ray_cast : RayCast2D
@warning_ignore("unused_private_class_variable")
var _wall_low_ray_cast : RayCast2D
var _player_ray_cast : RayCast2D
@@ -3,7 +3,8 @@ extends CultistWalkState
func init() -> void:
_direction = DIRECTION_LEFT
_wall_ray_cast = cultist.left_wall_ray
_wall_high_ray_cast = cultist.left_wall_high_ray
_wall_low_ray_cast = cultist.left_wall_low_ray
_player_ray_cast = cultist.left_player_distant_ray
@@ -3,7 +3,8 @@ extends CultistWalkState
func init() -> void:
_direction = DIRECTION_RIGHT
_wall_ray_cast = cultist.right_wall_ray
_wall_high_ray_cast = cultist.right_wall_high_ray
_wall_low_ray_cast = cultist.right_wall_low_ray
_player_ray_cast = cultist.right_player_distant_ray
@@ -15,7 +15,7 @@ func physics_process(delta: float) -> void:
if player != null:
switch_state.emit(chase_state)
else:
if _wall_ray_cast.is_colliding():
if _wall_low_ray_cast.is_colliding() or _wall_high_ray_cast.is_colliding():
var stream := SoundManager.sfx_stream_player_lost
SoundManager.play_sfx_stream(stream, cultist.global_position)
switch_state.emit(another_direction_walk_state)
+1 -1
View File
@@ -430,5 +430,5 @@ animations = [{
[node name="PlayerSprite2D" type="AnimatedSprite2D" unique_id=259457082]
material = SubResource("ShaderMaterial_i05k5")
sprite_frames = SubResource("SpriteFrames_v8w1g")
animation = &"fall_right"
animation = &"idle"
script = ExtResource("3_ulfbe")
@@ -4,13 +4,17 @@ extends PlayerState
func enter() -> void:
player.sprite.speed_scale = 1
SoundManager.play_sfx_stream(SoundManager.sfx_stream_death, player.global_position)
player.sprite.animation_finished.connect(_on_aniimation_finished, CONNECT_ONE_SHOT)
player.sprite.animation_finished.connect(_on_aniimation_finished)
player.process_mode = Node.PROCESS_MODE_ALWAYS
process_mode = Node.PROCESS_MODE_ALWAYS
player.sprite.play(PlayerSprite.ANIMATION_DEATH)
get_tree().paused = true
func exit() -> void:
player.sprite.animation_finished.disconnect(_on_aniimation_finished)
func physics_process(_delta: float) -> void:
pass
@@ -3,10 +3,14 @@ extends PlayerState
func enter() -> void:
player.sprite.speed_scale = 1
player.sprite.animation_finished.connect(_on_animation_finished, CONNECT_ONE_SHOT)
player.sprite.animation_finished.connect(_on_animation_finished)
player.sprite.play(_get_animation())
func exit() -> void:
player.sprite.animation_finished.disconnect(_on_animation_finished)
func _on_animation_finished() -> void:
switch_state.emit(idle_state)
+14 -7
View File
@@ -214,60 +214,67 @@ position = Vector2(2304, 2448)
[node name="Right_1" parent="Cutscene/EnemyWaves/WaveThree" index="0" unique_id=1741494130 instance=ExtResource("11_6yudq")]
position = Vector2(-69, 0)
animation = &"idle"
[node name="Right_2" parent="Cutscene/EnemyWaves/WaveThree" index="1" unique_id=761362258 instance=ExtResource("11_6yudq")]
material = ExtResource("13_x83dg")
position = Vector2(-77, 0)
animation = &"idle"
[node name="Right_3" parent="Cutscene/EnemyWaves/WaveThree" index="2" unique_id=418001405 instance=ExtResource("11_6yudq")]
material = SubResource("ShaderMaterial_6yudq")
position = Vector2(-87, 0)
animation = &"idle"
[node name="Right_4" parent="Cutscene/EnemyWaves/WaveThree" index="3" unique_id=1330937276 instance=ExtResource("11_6yudq")]
position = Vector2(-95, 0)
animation = &"idle"
[node name="Right_5" parent="Cutscene/EnemyWaves/WaveThree" index="4" unique_id=1285782564 instance=ExtResource("11_6yudq")]
material = SubResource("ShaderMaterial_8x4ch")
position = Vector2(-104, 0)
animation = &"idle"
[node name="Right_6" parent="Cutscene/EnemyWaves/WaveThree" index="5" unique_id=348811069 instance=ExtResource("11_6yudq")]
material = ExtResource("13_x83dg")
position = Vector2(-113, 0)
animation = &"idle"
[node name="Right_7" parent="Cutscene/EnemyWaves/WaveThree" index="6" unique_id=1822852735 instance=ExtResource("11_6yudq")]
position = Vector2(-120, 0)
animation = &"idle"
[node name="Left_1" parent="Cutscene/EnemyWaves/WaveThree" index="7" unique_id=2036807955 instance=ExtResource("11_6yudq")]
material = SubResource("ShaderMaterial_x83dg")
position = Vector2(78, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="Left_2" parent="Cutscene/EnemyWaves/WaveThree" index="8" unique_id=1125192387 instance=ExtResource("11_6yudq")]
position = Vector2(86, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="Left_3" parent="Cutscene/EnemyWaves/WaveThree" index="9" unique_id=1717461753 instance=ExtResource("11_6yudq")]
material = SubResource("ShaderMaterial_jbfb3")
position = Vector2(95, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="Left_4" parent="Cutscene/EnemyWaves/WaveThree" index="10" unique_id=1540913182 instance=ExtResource("11_6yudq")]
material = ExtResource("13_x83dg")
position = Vector2(105, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="Left_5" parent="Cutscene/EnemyWaves/WaveThree" index="11" unique_id=1177455845 instance=ExtResource("11_6yudq")]
position = Vector2(115, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="Left_6" parent="Cutscene/EnemyWaves/WaveThree" index="12" unique_id=1103369493 instance=ExtResource("11_6yudq")]
position = Vector2(123, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="Left_7" parent="Cutscene/EnemyWaves/WaveThree" index="13" unique_id=1686075717 instance=ExtResource("11_6yudq")]
material = ExtResource("13_x83dg")
position = Vector2(131, 0)
animation = &"look_around_front_2"
animation = &"idle"
[node name="WaveOne" type="Node2D" parent="Cutscene/EnemyWaves" index="1" unique_id=122551187]