Question about multiplayer tutorial

Hello, i am building the multiplayer code and checked the tutorial, i noticed that to delete players the code do this.players[data].deleted = true; since the code check if the deleted variable is true or false before apply the move code. Why is that? when the player log in again it will have the same id? shouldn’t be better to remove the player from the players array? Or the deleted one will be automatically removed from the array?

Hi @ayrin,

No they won’t be removed automatically from the array, their reference will remain in there.

Not sure what’s the intention behind that property. Out of my head I’d say in case messages are received out of order and involve moving a player already removed.

You could definitely rewrite that part any other way you see fit, make sure to test all use cases on your specific gameplay.

yes @Leonidas i’m already digging in my head to rewrite and add things i need in my game, not easy to make it work and it will become more complex when i will add database for players too. I try to solve 1 problem at time coz if i think foward about how i will handle parties of players i would give up right away :smiley:

1 Like