Files
Bomber-Thorsten/main.gd

24 lines
839 B
GDScript

extends Node2D
@export var player_scene = preload("res://player.tscn")
@onready var spawn_points = $PlayerSpawnPoints.get_children()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Spawn players at designated spawn points
for i in range(len(Global.player_ids)):
if i >= spawn_points.size():
break # Ensure we don't exceed available spawn points
var player_instance = player_scene.instantiate()
player_instance.set_input_id(Global.player_ids[i]) # Assign the input ID to the player
player_instance.global_position = spawn_points[i].global_position
$MultiTargetCamera.add_target(player_instance)
print(Global.player_ids[i])
add_child(player_instance)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass