0 votes

Hi, i'm trying to learn about networking system.
I'm doing a game that have two players in lan that one controls the move input and the other controls the attack input.
My server host is one of these players. So my question is...

Do I have to create a client for each player (even if that one acts as the server) and then store it into an array to be able to access to each player's properties?
Doing so the remote functions will execute in all clients, but will it execute twice in the host client if I use a sync function?

I saw this code by godot documentation http://docs.godotengine.org/en/3.0/tutorials/networking/high_level_multiplayer.html

remote func register_player(id, info):
# Store the info
player_info[id] = info
# If I'm the server, let the new guy know about existing players
if get_tree().is_network_server():
    # Send my info to new player
    rpc_id(id, "register_player", 1, my_info)
    # Send the info of existing players
    for peer_id in player_info:
        rpc_id(id, "register_player", peer_id, player_info[peer_id])

But with this code the server is not part of the players, how i should to adapt that to make it part. As another player?

asked Jan 17 in Engine by Raikish (87 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.