How to create/delete objects in muliplayer game?

I would like to ask for some help with the network extension of GD. I don’t now anything about networking and this is the very first time I try to use this extension to make a multiplayer game in GD. Thanks to the basic example and the tutorial on the wiki, I know how to set up a simple multiplayer game where we can share any information of existing objects between each recipients computer such as position, angle, size, animation. But what if an object is not exist at the beginning of the game or get deleted later? For example a bullet. If a player shoot a bullet how can I tell to other recipients to do the same? If player shoot bullets then shoot bullets on each computer if bullet destroyed then be destroyed on each computer… I guess I should send some kind of signal, message, value to each computer and let say “if crate bullet for player1 message is received then create object bullet at position of player1” or something but my problem is that, I can send values and text to recipients, but I have no condition to check if a specified value is received, I can use the value manly to update information of existing objects but how about non existing objects that I’m about to create or existing ones that I’m about to delete?

Anybody could help me with this? I don’t want a complete solution, example but some idea, theory at least that would help to move on because at the moment I have no idea how to move on with this. :cry:

You could use the network extension to send a message saying that an object has been deleted (you can use ID variable on objects).

Thanks Victor it worked:) What I’m doing actually, If I delete an object, I send a value to recipients and the recipients assign that value to an object variable(delete) and check the value of the variable, if object variable delete = 1 then delete object :slight_smile:

I have not tried it yet but I guess I can do something similar to create objects by using an object as a sensor. If I create an object I would send a value to recipients and the recipients would assign the value to an object variable of sensor object. If “player1_shoot = 1 of sensor object then create bullet at position player1”. I’m not sure if it the “proper way” but at the moment I can’t see other option. It already scares me how complicated it going to be :laughing:

Thanks again :slight_smile:

I’m still having trouble with this :blush:

I can create and delete objects on recipients computer, but I have trouble with identify the actual object and delete only selected object for each recipient. For example, let say I’m create 2 copy of the same object in different location, and later I want to delete only one of them. My problem is that I can’t identify the object on the recipients computer that needs to be deleted. I’m trying to generate unique ID number for each objects when it created and when I delete an object I send the ID number and position of object to recipients just before it get deleted, and I try to tell the recipients to delete the object in case of same ID number in same position but instead every single object is get deleted on recipients side, not only the one that has the same ID number in same position. Basically, the recipients receive the ID number and position of this object, and they can find the object with the same name, ID number in the same position of the scene but every object get deleted not only the one with the same ID number in same position.

I’m using the events like this:

Variable(object_deleted) = 1
Variable(ID) of object =Network::GetReceivedDataValue("delete_object_ID") : Delete Object
X position of object = Network::GetReceivedDataValue("delete_object_X")                   
Y position of object = Network::GetReceivedDataValue("delete_object_Y")                  

But it doesn’t work, it deletes every object not only the one with the specified ID in specified position.

Probably I should be able to send message directly to objects on the network and I just found some action to set objects to receive and send data on the network and to generate network identifiers for them. Maybe this is the solution for my problem, but I have no idea how to use them. Anybody could help me with this? Tried to use them the way I think it works, but it didn’t work. Or if it not for such purpose what is the purpose of these network actions to set object to send and receive data and to generate network identifiers for them?


EDIT:// I have solved the problem, there was a glitch with my ID number generation and title used to send/receive data, and also had a typo in title used for position values :stuck_out_tongue: . It works now :slight_smile: But still, if I supposed to use this “set object to send/receive data” actions and “network identifier” generation for such purpose, I would be glad if someone could help me with how to use them. Thanks.