Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Forecaster1310 |
Can I use Enet with c#?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Forecaster1310 |
Can I use Enet with c#?
Reply From: | MSDOGRA76 |
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");
}