I have a normal non ecs scene where the user can select what character class to play in a netcode for entities game. E.g. user selects to play as a warrior and then clicks to join game. What is best practise to pass this type of information to the server and client world systems? I am looking at shared static variable, maybe a short lived file in userappdata, but think that there must be a more basic standard approach, as this is a very common scenario, passing custom parameters when connecting a new client player to the server.
#Sending custom parameters when connecting a client to a server?
1 messages · Page 1 of 1 (latest)
Client should send rpc with selected class and server will spawn his character.
Connecting is for establishing communication between server and client, don’t try to combine it with some game logic.
This is what I am doing now (but as you can see hardcoded):
var commandBuffer = new EntityCommandBuffer(state.WorldUpdateAllocator);
foreach (var (id, entity) in SystemAPI.Query<RefRO<NetworkId>>()
.WithNone<NetworkStreamInGame>()
.WithEntityAccess())
{
commandBuffer.AddComponent<NetworkStreamInGame>(entity);
var req = commandBuffer.CreateEntity();
commandBuffer.AddComponent(req, new EnterGameRequest { NetworkId = id.ValueRO.Value, PlayerClass = new ByteId {Value = 2}});
commandBuffer.AddComponent(req, new SendRpcCommandRequest { TargetConnection = entity });
}
commandBuffer.Playback(state.EntityManager);