• 3D
  • Creating multiplayer with nodejs websockets

I am trying to make a 3d online multiplayer game. I am sending the player positions in a dictionary. How can I render the players with the proper name and position?

#For example I have a sample json
{"player1": {"x": 0.003, "y": 1.002, "z": 3.002}, "player2": {"x": 0.043, "y": 1.402, "z": 3.702}}
#I want to create players with the name on top

I have a KinematicBody Node with the name player. Please tell me how to render the players in proper positions.

    You'd have to parse the JSON first. https://docs.godotengine.org/en/stable/classes/class_json.html Then you can use get_node to get the player and and the function set to set the variables.

    get_node("player1").translation.set("x") = 0.003

    How to create the player1 node? That's what I am struggling on.

    So you need to load the scene first. Then call instance() and add_child().

    onready var player = preload("res://player.tscn")
    
    func _ready():
       var player1 = player.instance()
       add_node(player1)
    2 years later

    Irjk915 that's probably was very laggy stuff, right?
    have you found any ways of how to fix that node js ping?
    my model is shaking when it receives it's position..