0 votes

Can I use Enet with c#?

in Engine by (12 points)

1 Answer

0 votes

Yes, you can totally use Enet with C#

https://godotsharp.net/api/3.0.1/Godot.NetworkedMultiplayerENet/

small Sample from my game code:

public void CreateClient(string playerName)
{  
    //Global.MyName = playerName;
    GetTree().Connect("connected_to_server", this, "_connected_to_server");
    GetTree().Connect("connection_failed", this, "_connection_failed");
    GetTree().Connect("server_disconnected", this, "_server_disconnected");
    var peer = new NetworkedMultiplayerENet();

    peer.CreateClient(lobby.ServerIP, DEFAULT_PORT);
    GetTree().NetworkPeer = peer;
    GD.Print("Client created");
}

public void _connected_to_server()
{
    Global.MyID = GetTree().GetNetworkUniqueId();
    GD.Print("Client connected to the Server");
    RpcId(SERVERID, "RegisterPlayer", Global.MyID, Global.MyName);
}

public void _connection_failed()
{
    GD.Print("_connection_failed");

}
public void _server_disconnected()
{
    GD.Print("_server_disconnected");
}

public void _startGame()
{
    GD.Print("Sending RPC to start the game");
    RpcId(SERVERID, "StartGame");
}
by (16 points)
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.