red_dragon_pon/base/scripts/projectiles/hitscan.gd
2025-07-26 17:58:28 +05:00

16 lines
612 B
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends RayCast3D
var damage : float
func _ready() -> void:
if is_colliding():
var collider = get_collider()
# API говорит, что коллайдер может не оказаться нодой3д
if collider is Node3D:
# Проверяем, является ли ссылка на хитбокс, или нам дали ссылку на основной объект
if collider.is_in_group("enemy"):
collider.get_node("Entity").deal_damage(damage)
elif collider.get_parent().is_in_group("enemy"):
collider.get_parent().get_node("Entity").deal_damage(damage)
queue_free()