Hey there, I’m building an online rpg game where there are ~100 npcs, and I’d love to have 1000 players(don’t know the limits of kryonet). Anyway, I finally got the networking to work somewhat but my problem begins when taking connection.getID() on the server starts from 1, whereas client.getID() on the client starts at 0, simple enough to subtract 1 but I’m working in the 1000s and it gets confusing very fast.
Currently I generate the world on the server with actors 0-99 being npcs, then 100-999 are empty player classes that I update when a player connects/moves. On the client I have the same, with a stage with 0-99 being empty npcs off the map, when the server connects it tells the client to move all the npcs to their locations. Same with players. This feels super wrong generating 1000 actors when the game starts rather than dynamically creating and removing them.
The only reason I can’t do it right is I don’t know how to keep connection ids and stage actors related. Currently to update the servers actors im just doing stage.getActors().items[connection.getID()] etc, but if I remove a player the whole stage gets mixed up. How do I do this right??
My only idea is to give the player an id field and assign it with it’s connection id when it’s created. This seems exploitable and I can’t see it being efficient to search the whole list of actors each time I want to reference 1 player.