raycast now does not pierce walls
This commit is contained in:
parent
ca98b824a3
commit
388fe1ccce
3 changed files with 8 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue