raycast now does not pierce walls

This commit is contained in:
Rendo 2025-11-27 11:49:33 +05:00
commit 388fe1ccce
3 changed files with 8 additions and 3 deletions

View file

@ -218,7 +218,6 @@ script = ExtResource("4_smehm")
[node name="RayCast3D" type="RayCast3D" parent="Camera3D"] [node name="RayCast3D" type="RayCast3D" parent="Camera3D"]
target_position = Vector3(0, 0, -1000) target_position = Vector3(0, 0, -1000)
collision_mask = 0
script = ExtResource("4_fjrip") script = ExtResource("4_fjrip")
[node name="TeamUpdater" type="Node" parent="Camera3D/RayCast3D" node_paths=PackedStringArray("player")] [node name="TeamUpdater" type="Node" parent="Camera3D/RayCast3D" node_paths=PackedStringArray("player")]

View file

@ -3,3 +3,10 @@ extends RayCast3D
func _ready() -> void: func _ready() -> void:
add_exception($"../..") add_exception($"../..")
func try_deal_damage(damage) -> void:
if is_colliding() == false:
return
var collider = get_collider()
if collider is Player:
collider.hp -= damage

View file

@ -37,8 +37,7 @@ func fire() -> void:
machine.animation_player.stop() machine.animation_player.stop()
machine.animation_player.play(with_morphems("shoot")) machine.animation_player.play(with_morphems("shoot"))
if raycast.is_colliding(): raycast.try_deal_damage(damage)
raycast.get_collider().hp -= damage
fire_timer.start() fire_timer.start()
machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot)) machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot))