Hi there, I'm working on a client-server multiplayer game.
I want to send back a game update which contains all the players and their current positions, on the client I am going to iterate through this list and if the ID of the current player we are iterating through is the same as the client's ID then I want to use this to do some special rendering (that indicates you are controlling this player).
My question is if I have to implement this ID system myself or if enet gives unique ID's out on connection which can be used for this purpose.
Also I was trying to figure this out myself. Here's what I've looked at:
On the client side we start out by making an ENetHost, I looked into that struct but I saw nothing there about a unique ID.
On the server we wait for connections with enet_host_service specificially for a ENET_EVENT_TYPE_CONNECT which contains event->peer which is the peer which successfully connected. So I looked at ENetPeer which has a few attributes relating to ID's such:
are any of these what I'm looking for? (are we even supposed to access these attributes?) If someone can provide me with what these variables are/do I can document the code as well.
Also I found that enet_peer_get_id is a function that exists, but is not in the doxygen documentation when I searched it up, is this function what I'm looking for? If these getters exists are we not supposed to access the attributes directly?
I spoke to lsalzman and he said not to use that attribute because it is for internal use only and might not be unique, instead you can implement your own system which generates unique ID's for connected users
Hi there, I'm working on a client-server multiplayer game.
I want to send back a game update which contains all the players and their current positions, on the client I am going to iterate through this list and if the ID of the current player we are iterating through is the same as the client's ID then I want to use this to do some special rendering (that indicates you are controlling this player).
My question is if I have to implement this ID system myself or if enet gives unique ID's out on connection which can be used for this purpose.
Also I was trying to figure this out myself. Here's what I've looked at:
ENetHost
, I looked into that struct but I saw nothing there about a unique ID.enet_host_service
specificially for aENET_EVENT_TYPE_CONNECT
which containsevent->peer
which is the peer which successfully connected. So I looked atENetPeer
which has a few attributes relating to ID's such:are any of these what I'm looking for? (are we even supposed to access these attributes?) If someone can provide me with what these variables are/do I can document the code as well.
enet_peer_get_id
is a function that exists, but is not in the doxygen documentation when I searched it up, is this function what I'm looking for? If these getters exists are we not supposed to access the attributes directly?