How do I call functions on all peers (MP)

Get help using Construct 2

Post » Sun Aug 31, 2014 6:05 pm

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?

Code: Select all
if (message starts with "cmd: chest"){
play animation X}


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. Is there any other way to do it or to call a function on all peers simultaneously? I've read through all tutorials but still feel a little bit lost.

Cheers
Theo
B
14
S
2
G
1
Posts: 53
Reputation: 850

Post » Mon Sep 01, 2014 4:01 pm

bump
B
14
S
2
G
1
Posts: 53
Reputation: 850


Return to How do I....?

Who is online

Users browsing this forum: donstathemonsta and 32 guests