Help Multiplayer Object Instance Varible

0 favourites
  • 9 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I am making this multiplayer demo to learn how to program multiplayer games.

    The problem I am having is with the main sync object(tank). When a new player joins the game the computer will make sync object(tank) for all the other players already in the game. They show up in the right position and angle on the screen but all the instance varibles are set to their default state.

    How do I get all the other players Object(tank) instance varibles to sync up with the new joining player?

    My object(tank) has instance varibles like health,kills,deaths,speed and weapon that need to get sync up.

    I think the problem might be in my signalling group. I have tried playing around with it but nothing I've had tried seemed to work.

    You can play with what I have done so far here:

    I will also upload the cap file so you can check it out.

  • One way would be to have the host determine their values.

    Use sync variable and leave the client tag empty "" and do not add a client input value tag.

    This will force the value of the var to be the same as the host vars

    Now its just a matter of informing the host of what your value is (sent message with info to host, host sets variable based on that)

  • Thanks lennaert for the tips .

    I was playing with you in your multiplayer tank game Sunday. The game is looking great.

    Wish I could get a look at a early ver of your cap file so I could study how the multiplayer (Signalling, Host, Peer and Common Groups) all work together. LOL I am having a problem getting my head around the logic of multiplayer coding.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Multiplayer is actually easier then it appears, one quickly can get lost on who is telling who what to do ..... (I did lots of times )

    Signalling (not signal server) is actually just a small part, its the same as sending a message to all peers and have them set a state as the host sets it himself.

    Lots of times when I made a bug, it was because I was having actions performed twice due to sending info around too much.

    keep in mind:

    peer sent message to host to be broadcasted to all: perform action on peer, sent message to host

    host receives message from peer to relay to all: host performs action (same as peer just did) and sents a broadcast with information to all peers

    all peers (NOT! the original sender) : should receive the message and perform needed actions the original sender and host just did.

    Effectively, 1 action is performed 3 times. You, host and all other peers (not host and not you, because those 2 already did it)

    This process is about the same for every other aspect in a multiplayer game where you want a peers action/setting to be synched with all outside of the sync var functionality.

    Now with a bit of smart approaching, you can stuff near all general actions in 1 big for each peers loop in the common sheet, and have every body tell one another what their states are. Based on these states the loop performs needed actions for all the players (host and peers).

    big tip:

    when making sent and broadcast messages, becarefull with textuall content, also with their naming tags.

    just imagine

    Tag names:




    The tags are sent along too, the bigger/longer the names, the more data needs to be submitted, more overhead.


    message content:

    tag: "PlayerDied"

    message: "The player has died in a horrible way"


    tag: "pd"

    message: "1"


    on peer message received "pd"


    set text "player has died in a horrible way"

    In the second example, the text is taken from the event sheet, in contrast to sending it along.

    its like a couple K bytes vs several bytes.

  • Microsoft is hosting another Construct2 Teaching Session. This time it is advanced game development which includes multiplayer scenarios.

    Register for free here

    [quote:3kutuzim]Find out how to include privacy and support settings, and even add a leaderboard. Work with multiplayer scenarios, advertising, in-app purchases, and much more

    Looks like fun.

  • DUTOIT that sounds amazing! Try for the heads up, if I can attend I will, considering the multiplayer is my senior capstone, heh.

    Also lennaert thanks again for some of your tips on multiplayer.

  • Thanks DUTOIT for the heads up on that

    Lordshiva1948, yes I have been reading those tutorials over and over lol

  • DatapawWolf - if you miss it, like I always do, due to timezones. They are pretty good at having the videos/course materials up a day or 2 after.

    Maxum, the last course was very good... it was beginner, but had some nuggets in it. This is going to be pure gold

    lennaert, as always, great fedback.

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