How do I sync VARS with new players in a multiplayer game?

0 favourites
  • 6 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • I have a project where players can work together for a goal, that goal is dynamic but i do have problems when new players are joining after i limited that goal

    what i have right now

    - host create a room and wait in the lobby

    - players connect using a code generated random and wait in the lobby

    - host can press a button to start the game before or after the lobby is full (max 20 players)

    - goal is equal to current players*VAR(5)

    - start the real game

    - all players have the same goal number

    my problems

    if a new player want to enter in a non full room using the random code they can but they dont have access to the actual goal number, by default they would have VAR(5) and the other player will have a different goal

    my options are to limit players or learn how to sync this info all the time

    - a way to stop new players to enter in my room, i tried changing my room code but didnt work

    - how to share VAR that are changing during the game with new players that are joining to the room after the game started

  • You can use a common data helper object that is synced, there is a sync instance variable action in the multiplayer object.

    You can also have the host broadcast the message with the relevant information whenever it changes or when a new player joins, which is what I would recommend, as this variable is not something that needs to be updated 30 times a second.

  • You can use a common data helper object that is synced, there is a sync instance variable action in the multiplayer object.

    You can also have the host broadcast the message with the relevant information whenever it changes or when a new player joins, which is what I would recommend, as this variable is not something that needs to be updated 30 times a second.

    I like the idea but failed to do it

    I tried using using a common obj with an instance variable, I added sync obj and sync var, also the broadcast message to do some tests

    1st tried

    Host press a button (only visible to host) to convert a boolean to true

    that boolean (global boolean) set a random number of 4 digits into the instance variable

    text on screen show that instace variable to everyone

    results

    Host can see the random number and peers see the default text

    2st

    same example but everyone can press the button

    results

    everyone see a different value but only when they press the button, i need they to see the same value

    im not sure in what im failing, i need a dynmic value that can be changed only by the host when is needed and that value share to all players at same time

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You probably didn't set it up correctly. Without seeing what you did, I have no idea why you failed either.

  • You probably didn't set it up correctly. Without seeing what you did, I have no idea why you failed either.

    I think i did the most basic of the excersice i guess, players touch the button that is on the top and the number below should change to a random number, that number should be the same in both screen but im failing in something :c

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