need help with multiplayer

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • ok guys here is my problem

    im trying to make an multiplayer survival game but if i destroy an tree it will be only destroyed if im host here is my code

  • Here's a bit of a different thought of approach.

    Currently, with what you are attempting, there is a potential high bandwidth usage, with you trying to tell another player, at high interval, that something (a tree) is somewhere, and you will be trying to communicate regularly (sync) where its position and what its angle is.

    By any means, this is most inefficient.

    The tree wont move (at least, thats my expectation of a tree) so, telling other players its angle and position continuously is not helping aiding the mechanic of the game.

    You could try and have some a variable synced, telling the other player the state of the tree ... but this too .. is .. still too much. As it would continously check if some state has changed, and inform the other player.

    My apporach would be:

    If the map has been made in advance (on the layout editor), on both the host and the peer, then both the host and the peer already know where this static object is, the tree.

    Requiring the destruction of the tree on both ends, would only require 1 side, telling the other side, that a certain tree has been destroyed.

    Now, in actions and conditions: if I destroy a tree, send a message to the other player, containing ID of said tree, in a message indicating it has been destroyed on my end. In response, the other player receives the messages, and aptly destroys the same object.

    player

    Send message "destroytree" message "xxx" (some ID) to other player.

    other player

    on received message, "destroytree" , pick tree with id of lastmessage, destroy tree

    That just about sums it up for relaying the sate of a static object, with just 1 message, instead of a synced object, greatly reducing bandwidth/overhead.

  • i tried it but i still dont get it

    here is an screenshot

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are the UIDs ? the same ? I think not, you will require an ID thats the same on both ends.

    Several approaches:

    1. easy

    loop through your trees in a specific order, on both host and peer, during the loop, have the trees set an a variable, TreeID (number)

    This requires the loop method to be identical to get the same numbering on both ends.

    2. hard.

    -Destroy all trees on peer.

    -host loops through Trees, adding an ID, or reusing the UID to set a new ID

    Each tree gets broadcasted, wit X, Y, size, angle in 1 message per tree during game start; just once.

    -peers received the info during game start up and generate all the trees broadcasted by the host.

    After one of these, you can apply the mechanic from the previous post.

  • If im honest i dont understand anything what you said earlier

    can you please fix this for me

    here is Capx:

    drive.google.com/file/d/1T4PRARD_pzR-yIYgtSY9YID12_VsSTAJ/view

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