You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to make a game with socket.io and p2.js. I was thinking of sending the world instance to the client from the server, then having the client render it. I wasn't able to send the instance of world to the client because the object has a circular structure. Any idea of how to tackle this issue?
The text was updated successfully, but these errors were encountered:
Sending the whole world state every tick is extremely inefficient and practically useless. Try to send as little information as possible. For example, only send positions of the objects that move. Then apply this updates to the client's state. Game networking is a complex task
I use Socket.IO and P2.js for my real-time multiplayer game Deadswitch 3.
It's not possible to emit the world instance to a client (hence the maximum call stack error) due to circular dependencies.
Instead, simply send any position/velocity/data changes that occurred. I recommend sending this at a interval, not every frame. Personally I send data updates 5 times a second, and let the client handle interpolation.
I was trying to make a game with socket.io and p2.js. I was thinking of sending the
world
instance to the client from the server, then having the client render it. I wasn't able to send the instance ofworld
to the client because the object has a circular structure. Any idea of how to tackle this issue?The text was updated successfully, but these errors were encountered: