How do I call functions on all peers (MP)

0 favourites
  • 2 posts
From the Asset Store
Voice call plugin based on webrtc protocol for construct 3
  • Hi there,

    I got stuck at a small problem whilst working on an online game based on the multiplayer example by Scirra.

    Every player (e.g host & peers) should display an animation of an treasure chest opening simultaneously, when any of the players is opening it. To make it easier (without "getbit(Peer.inputs, 0)" etc) we just say that the host should presses "f" to play the animation on every client.

    I am fairly aware that this goes in the same direction as displaying a walking animation for each peer when he moves. I've already accomplished that but however I used an instance variable (peer.direction) for it. I set the direction-variable according to the input the host gets (1 = right, 2 = down, etc) and interpret it in the common event section.

    The thing I need for this particular problem is the peer.peerID to isolate the peer that was opening it in order to get it's position. Once I got the position I can look for the nearest instance of a treasure chest with the "pick nearest" event.

    It wouldn't make much sense to create a new synced instance variable for that, in which only the (last) peerID of someone who opened a chest is stored, would it? Furthermore would I need to add even more variables for every kind of action which will just slow down the game and as mentioned one shouldn't sync stuff that doesn't need to be synced.

    However would it be a good idea to send a chat command with the peerID and interpret it in the common group like this?

    if (message starts with "cmd: chest"){
    play animation X}[/code:3li4k1ei]
     I'd actually like to make only a "for each peer"-loop (@host) and then call a function within it but this won't work of course. [b]Is  there any other way to do it or to call a function on all peers simultaneously?[/b] I've read through all tutorials but still feel a little bit lost.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • bump

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