Adds lightning projectile

Implements a lightning projectile with visual effects.
The lightning is created using a series of bolt components that dynamically adjust their shape.
Also refactors the projectile system to use a base class.

Removes unused modifiers from player script.
This commit is contained in:
Dan Baker 2025-05-05 16:42:51 +01:00
parent ff62d67f54
commit d0c2a7b3c8
12 changed files with 239 additions and 103 deletions

View file

@ -0,0 +1,30 @@
class_name ProjectileLightning
extends ProjectileBase
@export var line_width: float = 1
@onready var lightning: Array = get_children()
func _init() -> void:
#super._init()
Log.pr("ProjectileLightning _init")
func _ready():
lifetime_timer = Timer.new()
add_child(lifetime_timer)
lifetime_timer.one_shot = true
lifetime_timer.wait_time = lifetime
lifetime_timer.connect("timeout", _on_lifetime_timeout)
lifetime_timer.start()
emit_signal("on_spawned", self)
connect("body_entered", _on_body_entered)
func _process(_delta):
for child in lightning:
child.goal_point = target_position
func _physics_process(delta):
position += direction * speed * delta
func _on_lifetime_timeout():
super._on_lifetime_timeout()