62e86f906f
A stale/incomplete Godot import cache made preload() of the sprite textures fail at COMPILE time, killing the actor scripts entirely — no movement, no draw, near-black screen (reported on the Mac editor after pull). Switching preload -> runtime load() degrades a missing texture to an invisible sprite instead of a dead script; movement and logic always survive. Committed state was verified sound via fresh clone (imports + main scene + smoke all clean); this hardens against the cross-machine cache-lag failure mode. Smoke 3/3 green.
36 lines
985 B
GDScript
36 lines
985 B
GDScript
extends Area2D
|
|
## KINETIC slug: damage plus knockback along its travel direction.
|
|
## Knockback is the load-bearing part — KINETIC is the one tag that
|
|
## touches the piloting layer, and the HEAT+KINETIC chemistry row
|
|
## (next slice) rides on impacts this weapon causes.
|
|
|
|
@export var speed := 420.0
|
|
@export var damage := 1.0
|
|
@export var knockback := 220.0
|
|
@export var lifetime := 0.8
|
|
|
|
var direction := Vector2.RIGHT
|
|
|
|
|
|
func _ready() -> void:
|
|
add_to_group("projectiles")
|
|
rotation = direction.angle()
|
|
# Runtime load, not preload — resilient to a stale import cache.
|
|
var spr := Sprite2D.new()
|
|
spr.texture = load("res://assets/sprites_ph/slug_ph.png")
|
|
add_child(spr)
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
position += direction * speed * delta
|
|
lifetime -= delta
|
|
if lifetime <= 0.0:
|
|
queue_free()
|
|
|
|
|
|
func _on_body_entered(body: Node) -> void:
|
|
if body.is_in_group("enemies"):
|
|
body.hit(damage, direction * knockback)
|
|
queue_free()
|