Multiplayer: Sync object destruction

Get help using Construct 2

Post » Wed Mar 26, 2014 5:24 pm

So I have player objects being synced between peers in a multiplayer mode. Ideally the player objects would be destroyed at the same time for all peers, they were easily created at the same time and move around just fine, but as soon as an event on the host side calls for destruction of the object, it immediately destroys it on the host side as expected but has a 2 or 3 second delay on the peer side. Is there a better way to sync the destruction of objects? There are a few other things that will be created that I'd like to have synced on just when they're created and destroyed, like bullets, but with that destruction delay it doesn't really work.

Edit: I should note that these are peer-associated objects. It actually has no problem destroying them immediately when the peer disconnects (which was unexpected behavior for me, but it works out alright). I don't know if that has some effect on the destruction speed.
B
4
G
1
Posts: 10
Reputation: 547

Post » Wed Mar 26, 2014 5:51 pm

If you associate an object with a peer, you are indicating that the object will exist for the same amount of time that the associated peer is connected. So you should not try to destroy it yourself - as you've noticed, it's automatically destroyed when that peer quits.
Scirra Founder
B
399
S
236
G
89
Posts: 24,525
Reputation: 195,382

Post » Wed Mar 26, 2014 6:09 pm

So what's the best way to destroy the object and still have the player be able to stay connected spectate the game until its end? Should I have the host send out a command to destroy it on the peer side? Or am I better of doing a fake destruction, making the object invisible and otherwise unable to be interacted with?
B
4
G
1
Posts: 10
Reputation: 547

Post » Wed Mar 26, 2014 7:28 pm

The Ghost Shooter: Multiplayer demo just makes dead players invisible. Is that why you want to destroy a peer-associated object? Because they've died?
Scirra Founder
B
399
S
236
G
89
Posts: 24,525
Reputation: 195,382

Post » Wed Mar 26, 2014 8:11 pm

Yeah, it would be a case of the player dying. I thought the Ghost Shooter multiplayer demo just re-spawned you at a different position on death, so I wasn't sure how the Multiplayer object handled object destruction. I'm designing the game to be match based, so the players start in a chat lobby until the host starts the game. Once the player dies in the match, they still get to watch the match to its end, at which point I'll probably throw everyone back to the lobby to start a new match if they want.

After playing with it, looks like hiding the player object is the only option unless there's a way to disassociate the object after it's been associated. I'll have to go through and add a check in a few events to disable all interactions with the "dead" player and cancel out inputs, collisions and bullet overlap checks (does disabling a Sprite's collisions disable overlap checks as well? Overlapping at Offset seemed like the easiest way to test for bullet collisions with lag compensation). Bit more work, but not too bad.
B
4
G
1
Posts: 10
Reputation: 547


Return to How do I....?

Who is online

Users browsing this forum: AnD4D and 21 guests