On peer disconnected will have old peer count

From the Asset Store
Be quick and count the cards and choose the right number!
  • Hello there.

    For the ready check of my game I was trying to do the following logic:

    On peer disconnected {
    	If peer count = 1 {
    		Destroy Ready Button
    	}
    }
    

    Because if there are no other players there is no need for a ready button. The problem is, inside On peer disconnected it will still count the disconnected peer(s).

    For example:

    There are two players. Host and peer. The peer disonnects. Hosts On peer disconnected will trigger. Inside I have an Browser Alert Multiplayer.peerCount. It shows 2 although the second player just got disconnected.

    Is this a bug or intended? As that makes some if player leaves change stuff things difficult. Thanks in advance.

    Edit:

    This is my temporary fix. It works, although it looks funny. :D

    Multiplayer.PeerCount -1 = 1

  • It is possible that you'll get the actualised PeerCount on the next tick of execution.

    So consider adding a "Wait 0" action before your log to see if things change.

    If so, you can delay the destruction of your buttons as part of a function that you call after the "Wait 0" action.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried it and it worked without using a function. When I put Wait 0 or Wait for previous actions to complete it will have the correct peer count.

    Thank you!

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