35 lines
851 B
GDScript
35 lines
851 B
GDScript
extends Node3D
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func pow() -> void:
|
|
var going = true
|
|
|
|
while going:
|
|
$Hit.force_raycast_update()
|
|
var hit = $Hit.get_collider()
|
|
|
|
if not hit:
|
|
print("hit nothing")
|
|
break
|
|
|
|
if "health" in hit:
|
|
hit.health -= 100
|
|
if "on_knockback" in hit: hit.on_knockback()
|
|
print(hit.name, hit.health)
|
|
else:
|
|
print("no health in hit: ", hit.name)
|
|
break
|
|
|
|
$Hit.add_exception(hit)
|
|
|
|
$Hit.force_raycast_update()
|
|
var final_point = $Hit.get_collision_point()
|
|
|
|
$Line.position.x = -(final_point - global_position).length() / 2.0
|
|
$Line.height = (final_point - global_position).length()
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
$Line.radius -= delta * 0.2
|
|
|
|
if $Line.radius <= 0.001: queue_free()
|