[04]プレーヤーのバレットを追加
バレットはArea2D。プレーヤーと同じようにスプライトとコリジョンを設定

プレーヤーシーンに追加してバレットの大きさをチェック

バレットを削除して発射位置用のMarker2Dを設置

バレットのコリジョンをEnemyに当たるように設定。TopLevelをオンにするとプレーヤーの動きに左右されない

バレットのスクリプト
プレーヤーとの距離を指定しないとどこまでも直進するが、3秒後に消す
extends Area2D
# 移動スピード
const move_speed = 300.0
# プレーヤーからの距離
const bullet_range = 500.0
var direction = -1
func _ready() -> void:
await get_tree().create_timer(3).timeout
queue_free()
func _physics_process(delta: float) -> void:
position.y += direction * move_speed * delta
# プレーヤーから指定距離離れたら消す
var player = get_tree().get_first_node_in_group("player")
var distance = global_position.distance_to(player.global_position)
if distance > bullet_range:
queue_free()