0
\$\begingroup\$

My question relates to content rotation and data management of the emerging objects in a database.

I assume a networked game, with a server-client model. Unspecified objects in the game world are rotated while the game is running with algorithms. The players can modify the properties of these objects but have to notify the server of these changes. How could this communication address unique objects, so that both the server and the client know of which object they are speaking?

Not only the inner properties of the objects can differ, but also visible, such as the position. When the player wants to select one of these objects the game has to find out the id - does anyone know which methods or algorithms can accomplish that?

\$\endgroup\$
5
  • 5
    \$\begingroup\$ Usually the server would track an ID number for each object. When a player joins the game, the server would say "here are all the objects you can see, and their ID numbers". From that point onward, both the server and player client have a unique ID number for each object that matches its counterpart on the other end of the network connection, and they store those IDs locally. If a new object gets created through a server-side or player action, the client gets an ID for it from the server as part of the creation action. Is that approach not applicable to the scenario you're imagining? \$\endgroup\$ Commented Oct 8 at 1:56
  • 1
    \$\begingroup\$ It may also help to clarify whether by "rotation" you mean literally spinning / turning an object through an angle, or whether you're using the word more abstractly to mean "processes that cause the set of active objects to change over time, with some objects leaving the game and others entering"? \$\endgroup\$ Commented Oct 9 at 4:05
  • \$\begingroup\$ @DMGregory I am literally talking about spinning and the object through an angle. \$\endgroup\$ Commented Oct 9 at 15:55
  • 1
    \$\begingroup\$ OK. Does the "server gives each object a unique ID number, so all parties can refer to it unambiguously by that number" approach answer your question, or do you have a constraint that demands another approach? \$\endgroup\$ Commented Oct 9 at 21:07
  • \$\begingroup\$ @DMGregory Yes, it does give each object a unique ID number. \$\endgroup\$ Commented Oct 9 at 22:13

1 Answer 1

2
\$\begingroup\$

Converting my comment to an answer:

Usually, the server would track a unique ID number for each object. (Maybe sequentially assigned, maybe generated hashes / GUIDs).

When a player joins the game, the server would say "here are all the objects you can see, and their ID numbers".

From that point onward, both the server and player client have a unique ID number for each object that matches its counterpart on the other end of the network connection. Each side stores those IDs locally with their copy of the object, so they don't need a special algorithm to re-generate it or look it up.

If either side changes something about the object, they tell each other "I've just changed object #xxxx in this way...", so the recipient can unambiguously identify the corresponding object in their own copy of the scene and update it to match. (And, for the server, relay that change to all other clients who should see it). Rotation doesn't need to be handled in any particularly special way.

If a new object gets created through a server-side or player action, the client gets a unique ID for it from the server as part of the reply to their creation action. The same goas for if the player moves around and encounters new objects that weren't visible from their initial spawn location: in response to the "move" action, the server replies "here are the new objects you can see from there, and their unique IDs".

That fundamental idea should be enough to handle most cases of object identity and replication/synchronization over a network. If you have a special circumstance in your game that makes this more complicated, you can post a new question describing that complication in detail, an users here can suggest ways to handle it.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.