How do I Destroy Objects, Multiplayer

Get help using Construct 2

Post » Thu Sep 11, 2014 7:56 pm

I have a simple game, 2 player shooter with blocks to destroy.

Everything is working great in MP with the players and controls, but I'm having a hard time figuring out how to destroy objects.

Both players shoot the same bullet (whiteBullet), and when it collides with a grey block, it should destroy that block. I have a group that handles the white bullet collisions and I am turning that group off for the peer so the host handles all the collision checks. Problem is the destroying of the block works on the host side, but on the peer side the blocks stay, although their collision is gone as I can then shoot "through" them.

I've tried syncing grey blocks with the multiplayer object and no luck. So what is the best way to sync when and object has been destroyed on the peer side?

Hopefully I explained that well, if not I can make up some videos.
Thanks.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Thu Sep 11, 2014 8:18 pm

@ArcadEd
Off top of my head...

Create a instance variable on grey blocks called destroy
when hit mark as 1

Sync grey blocks variable destroy on start of layout as you did...

Now in common game components do a check.
Compare instance variable greyblacks destroy = 1 then destroy

Something like that I think.
Last edited by DUTOIT on Thu Sep 11, 2014 8:20 pm, edited 1 time in total.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Sep 11, 2014 8:19 pm

Object collision, creation and destroy is one of the many action that is considered authoritative, so you need to get the action to be executed from host. Singular action like these are usually done using the Action:Send Message (reliable mode) because you probably need them to be triggered in sequential manner. However to update peers you may lower the reliability mode of broadcasting from host if it is just for visual update. Data sensitive communication should always use reliable mode though.

To use peer as collision checker is possible but this will be difficult to stay sync in small lag margin, but on the other hand, if the host is the collision checker, it will strain some performance from the host, if host is a player.

I would say big rooms (more than 20 players) will require dedicated server (can be done within C2) with no visual or by creating artificial collision checks. Artificial collision check is by far the most difficult thing I ever encountered in C2 :O

I've done a few test so far what I see is hosting 2-8 players by client as host is acceptable (browser performance test). However I never tried against mobile, but my verdict is mobile probably are fairly acceptable in 2-4 players in number. This is in sense of real time gaming, but for asynchronous game, like turn based games would be no issue at all.
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Post » Thu Sep 11, 2014 8:28 pm

Thanks gang.

This is only a 2 player game, so I'm not too worried about performance there. I'll look over both suggestions, thanks again for the advice.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Thu Sep 11, 2014 9:09 pm

@DUTOIT If I have 100 blocks, do I need to do a foreach and sync every block? Because it doesn't seem to be working with just the single statement.
Image

If so, I may try out DFN's suggestion and use send message, once I learn about it :).
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Thu Sep 11, 2014 9:22 pm

ArcadEd wrote:@DUTOIT If I have 100 blocks, do I need to do a foreach and sync every block? Because it doesn't seem to be working with just the single statement.
Image

If so, I may try out DFN's suggestion and use send message, once I learn about it :).


Just did a quick test, and it didn't work as I expected it to.
Try DFN's suggestion. I will have to think this through. lol.

Issue is that instance variable isn't sync'd. I had to double click object. click 1 on host click 1 on peer to destroy.
Its midnight, so brain isn't working as it should.
Last edited by DUTOIT on Thu Sep 11, 2014 9:27 pm, edited 1 time in total.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Sep 11, 2014 9:26 pm

Yeah, that's what I found too. I'll try the other way and report back.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Thu Sep 11, 2014 9:32 pm

Sorry edited above...

Will have a look tomorrow after a few hours sleep.
Couldn't one just send a message to other player? If it only 2 players you could upon trigger destroy send peer/host a message to destroy.... No, no, that is the purpose of syncing the instance variable, why isn't instance variable syncing??? It should just sync objects instance variables.
I'll have to look tomorrow. ;)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Sep 11, 2014 9:46 pm

I think I got it, I was forgetting to destroy all the grey blocks if I am connecting as a peer. Now if I sync greyblock with position it works without the need for the variable.

I went into debug and noticed there was 180 grey blocks on created instead of 90 :).
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Fri Sep 12, 2014 6:36 am

So far I think sync instance variable probably only useful to change the object state (done by host) to "sync" animation or conditional highlighting for exclusive peer only.

As far as object creation and destroy is concerned, I still think it is the best to go with host, because you can minimize communication requirement from peer relay style to one-way authority style.
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests