Skip to main content
GameDev.net gamedev.net
🔒 Locked

Object Selection - over network

Started by Doggan Aug 2, 2006 at 12:54 PM 0 replies 800+ views
Original Post
Doggan
Doggan
I am working on the networking component for a virtual environment (aka virtual reality) simulator. The architecture follows the client/server model. It is very loosely coupled with the main program. If we want to use the networking module, a line is added to a startup script which dynamically loads the network library. If the line is absent, the application works just the same but w/o any networking. The networking for user representation is complete: Multiple users can connect to the server. You are able to view the other users in the simulation (headsets, gloves, etc). One of the main goals we have is user-interaction. There is a device that can be connected, called a 'wand', which is a mouse that can be used in the 3D environment. There are buttons on the wand that allow the user to select objects, move/throw them around (real-time physics system). I am trying to think of how to do this in a networked environment. Here are some of my ideas: The server should be authoritative. It owns the master state of the world, which is 'ghosted' onto the client machines. The clients also have a local copy of the state of the world, but it may be 'non-current' since the server hasn't told the client to update yet. Each object in the world has a boolean flag: isSelectable. This flag is initialized to 'true'. When a user selects the object, the flag is set to 'false' so that another user cannot select the object at the same time. Solution #1: Let's take an example with 2 clients (C1 and C2) and a server. There is a crate in the environment that can be selected by either client. C1 attempts to select the crate. C1 checks his local copy of the crate object, and sees that 'isSelectable == true'. C1 sends a message to the server that the crate has been selected. The server sets it's master copy of the crate to 'isSelectable = false', and sends it out to C1 and C2 who both update their local copies. If C2 now tries to select the same crate, he checks his local copy, and sees that the flag is false, so no selection occurs. - Problem: If C1 and C2 both attempt to select the same crate at nearly the same time (before the server has a chance to receives the first message and broadcast it back out), both clients will think they have selected the object - I'm not really sure what would happen here, but it can't be good. Solution #2: A similar situation as #1, but instead of checking the local client game state, query the master copy held by the server to see if the object is selectable. There will be no more problems with two users selecting the same object at the same time. - Problem: Latency. We now need to send a message to the server and await a return message before selecting an object. Since it is a virtual simulation, this sort of thing is a huge problem. Solution #3: Merge #1 and #2. Take the positives of #1: instant response time. When a user selects an object, check the local copy, and select the object. Send the message to the server. The server will detect if more than 1 user is trying to select the same object at the same time. If it detects this, it will send a message to all clients (except the first one) to deselect the object. - Problem: This could cause some strange behavior that would only arrise when two clients try to select the same object at the same time (which is probably very unlikely). When this happens, a client would think he has selected an object, but suddenly that selection is lost. Solution #3 seems like the best route that I can think of currently. There's also an idea similar to Half-Life 2, but I need to think about this some more. Using the gravity gun (or physics gun) in a multi-player setting, multiple users are allowed to select the same object at the same time. If they do 'opposite' movements, though, the person who selected the object first has first priority in moving the object (i.e. the object will listen to the first person only). I am not too sure how this would be implemented though... Wow, long post. Hopefully I can get some feedback! Thanks for reading.
hplus0603
hplus0603
The company I work for, Forterra Systems, has a distributed simulation platform called OLIVE (Online Live Interactive Virtual Environment), used for some MMOGs, training applications, and various research. We have solved this problem (and many others related to time dilation and frames of reference :-). Generally, whomever gets the object first on the server, gets it. Meanwhile, we display the object as gotten on the client when attempting to get it. If there is contention, the loser is corrected to the state where the object wasn't gotten.

In UI, you could express the "optimistic" selection using one kind of highlight, and the "authoritative" selection using antoher kind of highlight, to make it clear to the user what the transition is; if you lose the contention, it'll flash from normal to optimistic to normal, without going to authoritative, which will likely be understandable.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.