Hacker News new | ask | show | jobs
by mrspeaker 1671 days ago
Great article - couple of questions:

"when the server adds the scene to the SceneTree, it automatically sends that information remotely. Each connected client will then instantiate the scene automatically,"

What information does it send remotely? Is it all the 3D info for every object? "Put a cube at 10,10,10, with scale 1, rotation 0 etc"?

"The RPC system will also work appropriately for the nodes spawned this way, so you can easily integrate state synchronization with messaging."

What is "messaging"? Why is integrating state synchronization with messaging a useful thing?

2 comments

Did you read the article? The code sections show the player_name and position variables being synced with the position being synced every 16ms/62.5Hz.

The sentence right before your first quote answers your question -

"Note that the client code doesn't "instantiates" the scene explicitly. However, since the scene is marked for replication [... your quote]"

In this case its sending the scene for the clients to instantiate.

They gave an example of messaging as well - RPC.

Hmm, I've read it a bunch of times now but am still unsure: they ARE sending every bit of data - position, scale, rotation etc - about every cube/model/asset for a scene ("Since the scene is marked for replication [...your quote]")... and then after that they are syncing selected properties of that data ("player_name", "positions") every 16ms. Is that right? If you have a Fortnite-style map, every time you joined a game you would get all the map/model pos/rot/scale data sent to you?

And for messaging, I wrote "Why is integrating state synchronization with messaging a useful thing?" but I guess it would have been clearer if I asked "Why is integrating state synchronization with RPC a useful thing?"... what are some examples of what that's used for?

That does sound right. Apologies if my tone was rude earlier I was posting with little sleep.

I believe you want state sync and RPC integrated because you want a meaningful order to events.

Say a bomb exploding is done via an RPC call for legacy reasons and now position is via state sync. Youd want to ensure the explosion was ordered in respect to position updates to ensure it goes off in the right place.

What information does it send remotely? Is it all the 3D info for every object?

For most games, no. For big 3D virtual worlds, yes. This is a big difference between games and "metaverse" systems. Most games use a big bulk asset download, rather than dynamically loading assets is needed. What to load next at what level of detail given the current location of the camera has to be well handled to provide a good user experience. It's similar to the problems of displaying a partially loaded web page, only in 3D in real time with far more content.