diff --git a/scenes/molikman.tscn b/scenes/molikman.tscn index df0de5c..5e6193b 100644 --- a/scenes/molikman.tscn +++ b/scenes/molikman.tscn @@ -218,7 +218,6 @@ script = ExtResource("4_smehm") [node name="RayCast3D" type="RayCast3D" parent="Camera3D"] target_position = Vector3(0, 0, -1000) -collision_mask = 0 script = ExtResource("4_fjrip") [node name="TeamUpdater" type="Node" parent="Camera3D/RayCast3D" node_paths=PackedStringArray("player")] diff --git a/scripts/player/player_raycast.gd b/scripts/player/player_raycast.gd index be9dc1f..07277ed 100644 --- a/scripts/player/player_raycast.gd +++ b/scripts/player/player_raycast.gd @@ -3,3 +3,10 @@ extends RayCast3D func _ready() -> void: add_exception($"../..") + +func try_deal_damage(damage) -> void: + if is_colliding() == false: + return + var collider = get_collider() + if collider is Player: + collider.hp -= damage diff --git a/scripts/weapon_system/gun/semi_auto_shoot_state.gd b/scripts/weapon_system/gun/semi_auto_shoot_state.gd index 06ae88a..292475a 100644 --- a/scripts/weapon_system/gun/semi_auto_shoot_state.gd +++ b/scripts/weapon_system/gun/semi_auto_shoot_state.gd @@ -37,8 +37,7 @@ func fire() -> void: machine.animation_player.stop() machine.animation_player.play(with_morphems("shoot")) - if raycast.is_colliding(): - raycast.get_collider().hp -= damage + raycast.try_deal_damage(damage) fire_timer.start() machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot))