I'm trying to code a 3d fps game with a multiplayer and used the project of GDQuest to try out the multiplayer API and it worked well in 2d but not in 3d. The problem here is that I created a "_init" function in my Player script which
extends KinematicBody
func _init(nickname, start_position, is_slave):
label.text = nickname
velocity = start_position
if is_slave:
print("is slave: " + is_slave)
then in the World.gd I call it in the _ready() function to paste the info of each player for preloading
extends Spatial
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
get_tree().connect('network_peer_disconnected', self, '_on_player_disconnected')
get_tree().connect('server_disconnected', self, '_on_server_disconnected')
var new_player = preload('res://Player.tscn').instance()
new_player.name = str(get_tree().get_network_unique_id())
new_player.set_network_master(get_tree().get_network_unique_id())
add_child(new_player)
var info = Network.self_data
new_player._init(info.name, info.position, false)
the network self_data looks like this:
var self_data = { name = '', position = Vector3(0, 1, 0) }
when I start it shows a normal menu for hosting/ joining but when it tries to instance the Player it fails with the above error message.
The question is, why does it not work? I have the function in my Players' script and it shows the function when i type in 'new_player.'
