local Multiplayer support
This commit is contained in:
16
main.gd
16
main.gd
@@ -1,9 +1,21 @@
|
||||
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:
|
||||
$MultiTargetCamera.add_target($Player)
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user