0 votes

HI i have a question because nearly i start make a multiplayer game and project gone fine but tutorial aobut multiplayer in godot are written mostly in gdscript. I tried translate gdscript to c# but i dont understand some functions in gdscripts. So i asking you what is bad in under code or somebody know good tutorial how to make multiplayer game in c#? in general sorry for my bad Englidh

    TextEdit textEdit;

string ip = "192.168.0.100";
int port = 31400;
int max_client = 2;

public override void _Ready()
{
    textEdit = GetNode<TextEdit>("TextEdit");
}

public void enter_room()
{
    textEdit.Text = "Successfully joined room\n";
}


public void create_server()
{
    var peer = new NetworkedMultiplayerENet();
    peer.CreateServer(port, max_client);
    GetTree().SetNetworkPeer(peer);
    enter_room();

}

public void join_server()
{
    var peer = new NetworkedMultiplayerENet();
    peer.CreateClient(ip, port);
    GetTree().SetNetworkPeer(peer);
}

private void _on_Create_pressed()
{
    create_server();
}

private void _on_Join_pressed()
{
    join_server();
}

private void _on_Send_pressed()
{
    var id = GetTree().GetNetworkUniqueId();

    Rpc("recieve_call", textEdit.Text);
    GD.Print(id);
}

public async void recieve_call(string msg)
{
    textEdit.Text += msg + "\r\n";
    GD.Print(msg + " p");
}
asked May 21 in Projects by daniel500013 (64 points)

Do you have a link to the Tutorial you tried to use? Maybe I can help you to translate that into C#.

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.