0 votes

Hi everyone, i'm learning some Godot and GDScript and i'm using Multiplayer Bomber one scripts but for a custom 3D game, i want to spawn 2 players but i can't achieve it. How can i achieve spawn that players on multiple Position3D node in the scene ?

Here is the code from Multiplayer Bomber where players spawns:

remote func pre_start_game(spawn_points):
# Change scene.
var world = load("res://world.tscn").instance()
get_tree().get_root().add_child(world)

get_tree().get_root().get_node("Lobby").hide()

var player_scene = load("res://player.tscn")

for p_id in spawn_points:
    var spawn_pos = world.get_node("SpawnPoints/" + str(spawn_points[p_id])).position
    var player = player_scene.instance()

    player.set_name(str(p_id)) # Use unique ID as node name.
    player.position=spawn_pos
    player.set_network_master(p_id) #set unique id as master.

    if p_id == get_tree().get_network_unique_id():
        # If node for this peer id, set name.
        player.set_player_name(player_name)
    else:
        # Otherwise set name from peer.
        player.set_player_name(players[p_id])

    world.get_node("Players").add_child(player)

# Set up score.
world.get_node("Score").add_player(get_tree().get_network_unique_id(), player_name)
for pn in players:
    world.get_node("Score").add_player(pn, players[pn])

if not get_tree().is_network_server():
    # Tell server we are ready to start.
    rpc_id(1, "ready_to_start", get_tree().get_network_unique_id())
elif players.size() == 0:
    post_start_game()

Thanks in advance for the help !

Godot version 3.3.2
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.