How do I Destroy Objects, Multiplayer

0 favourites
From the Asset Store
Now you can drop everything in your game with sound :)
  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

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

  • 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.

    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.

  • Yeah, that's what I found too. I'll try the other way and report back.

  • 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.

  • 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 .

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

    Value your input, and I agree. The sync instance variable doesn't perform as expected(at least how I would expect it to).

  • I have problem long time ago wit similiar problem, thats why im not working on multiplayer, its really confusing even if i work on c2 two years.

    i got this same problem, i use sync to all my blocks BUT in my game on start of layout system create 5 random position blocks. Result is... on host side is diferent positions than on peer side. Any ideas how fix this?

    Ashley please add to existed example of multiplayer shooter few blocks to destroy because answer for this problem is missing on forum

    That will be great

  • I'm late to this thread, but it should be really simple. Use 'Sync object' to sync the blocks, and then destroy them on the host. When synced objects are destroyed on the host, the syncing automatically destroys them on all of the peers as well. So you don't even need to send any special messages or have any special flags.

  • Ashley I use on start of layout-> sync object, every tick- > sync object. I add this action on under 'Peer' 'Host' and 'common' group and if projectile collide on block this also dont work

    I think we need more multiplayer examples with included, hp bars, destroying entities, switch weapons, more examples or one example updates.

    Its really diferent and confusing when make simpliest multiplayer game.

    Conventional ways of creating games do not work .

    I feel like three years ago when I first used the Construct 2 im greenhorn

  • every tick- > sync object

    I don't think you should use it like this, it supposed to be trigger once, right?

    I think we need more multiplayer examples with included, hp bars, destroying entities, switch weapons, more examples or one example updates.

    HP bars

    Keep data on host, only sync instance variable for display.

    Destroying entity

    This should be covered by host.

    Switch weapon

    Peer send a message (reliable), host receive it then process/update to all peers -or- change the instance variable so all peers have updated visual. mechanic wise as in the damage amount done by certain weapon is still best covered/calculated by host.

    Ashley If I were to suggest a new official example, I would say a turn based game (bingo or tictactoe) or something like rock-paper-scissor. This is to emphasize correct use of send message and broadcast message which I think most people disregard it's awesomeness.

    Note: Beginners really hooked to sync object, and thinks it's the only way to sync things, based on my observation of question thrown out before.

    I don't know what is the philosophy of other people use for multiplayer, but my philosophy is , host=calculator, peer=visual update only. If the host is player then host=calculator/visual update.

    Maybe the only MP beginner tips that I can give is do not calculate anything on peer.

    Its really diferent and confusing when make simpliest multiplayer game.

    The pong example is a great example of how a small [2-5 event] game will turn out if MP implemented. It's that kind of "**upscaling**".

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)