Open ghost opened 4 years ago
Nevermind, I made a custom flattening script. Now my server can't do world.step(1/30) because it returns a maximum call stack reached error.
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.
Let me know if you have any other questions!
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?