I'm making an online RPG that could classify as an MMO, but I'm keeping the project scope very small by making the game's systems simple, and focusing mostly on what I want to learn: real-time networking.
The problem I'm facing is that that I don't want to update every player about every other player, all the time. This is a huge waste of bandwidth, and may even be impossible without a really beefy connection.
My solution is:
- Keep track of which entities are in the client's visibility range
- Send a "full entity state" packet when the client enters the world
- Send a "create entity" packet for any entity that enters the visibility range
- Send a "delete entity" packet for any entity that leaves the visibility range
- Send a "update entity" packet for any entity that updates within the visibility range
I don't like the fact that when the client moves, I have to update the list of entities it can see, because it means I still have to loop over every entity. Is there anything better? Can this solution be improved somehow? If so, could you provide further reading, or possibly even sample implementations?