Some multiplayer questions - could someone please educate?

Discussion and feedback on Construct 2

Post » Tue Oct 21, 2014 10:12 am

'Sync instance variable' doesn't support text, only numbers. The manual entry didn't mention that so I updated it to include that.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Tue Oct 21, 2014 11:55 am

Thanks @Ashley. I have also noticed that in Pong example -> Peer group - on-created paddle event - set Paddle.peerid to multiplayer.peerid works only for one single instance of Paddle. In any game, lets say if I want to create multiple paddles (by sending create message from peer to host , using sync object) then the remaining instances of paddle on peer side doesn't get set to multiplayer.peerid...they are getting set to blank. The Pong example says that sync object should automatically get the multiplayer.peerid on peer side when a paddle gets created...This seems to work only for the first instance of paddle on peer side and doesnt work for remaining instances...
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Tue Oct 21, 2014 12:02 pm

Have you looked at the real-time game example? Pong is hard-coded to use 2 players, whereas the shooter game works with any number of players.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Tue Oct 21, 2014 12:38 pm

@Ashley, I did look at real-time game example...Even in real-time game, there is only a single instance creation of a sprite called "Peer". But my question is even there are only 2 players or "n" number of players, I want to create multiple instances of sprites for each Peer...And I want to associate all instances of sprites created by a particular peer to that peerid....In such case, inside the peer group if I have an event like - on-created sprite event - set Paddle.peerid to multiplayer.peerid action sets the peerid only for the first instance of the sprite...The peerid for all other instances is blank using this approach...somehow sync object is not syncing for the remaining instances of peer sprites ...Hope I am clear..
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Wed Oct 22, 2014 3:17 am

kmsravindra wrote:I have to spawn a new sprite on peer or host whenever the user double clicks on a screen...While I was able to get this working, I am not able to update the sprite.peerid with the peerID's of the user who creates them...I am using "Sprite - oncreated" event on peer and then assigning it to multiplayer.peerID...(as per the example multiplayer.peerID is supposed to contain the peerID whenever sync object creates a sprite on the host)...Strangely multiplayer.peerid gets set only for very first sprite that gets created on the peer / host...The sprites that get created from then on have blank values in their peerid instance variables..I am sending a message to host to create a sprite whenever peer double clicks on screen...

I'm not sure if you're having the "not yet created" issue here, but I think this might be the case. I have issue before with similar like this but different. Ashley introduced wait for signal a few release back which solved this issue.

I'll explain my case, I'm not entirely understand the technical work on the back of it but I hope this help:
I think sync object is sync 1/30 second so there's a chance that the data arrive is not in desirable order when used in parallel with send message. However, reliably ordered message are guaranteed to arrive in order if it is a case of between broadcast and send. There's a chance the sync data arrived the tick before the send message arrive which theoretically confirms why wait for signal works.

Tl;dr, experiment with wait for signal in the on created event. Actual snapshot of my simplest case:
Image
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Post » Wed Oct 22, 2014 3:21 am

kmsravindra wrote:@Ashley, I did look at real-time game example...Even in real-time game, there is only a single instance creation of a sprite called "Peer". But my question is even there are only 2 players or "n" number of players, I want to create multiple instances of sprites for each Peer...And I want to associate all instances of sprites created by a particular peer to that peerid....In such case, inside the peer group if I have an event like - on-created sprite event - set Paddle.peerid to multiplayer.peerid action sets the peerid only for the first instance of the sprite...The peerid for all other instances is blank using this approach...somehow sync object is not syncing for the remaining instances of peer sprites ...Hope I am clear..

You either want to look at container or independent sprite like RTS?

I haven't look at RTS yet but I think that'll be one hell of a job. :shock:

Looking at your name I think you're an Indian, happy celebration then!
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Post » Wed Oct 22, 2014 3:52 am

@DuckfaceNinja, Thanks a lot for the wishes and for the inputs..."wait for signal" looks promising to give it a try...Will do that and post here if it worked...

I am already using container objects...Also I was able to get most of it working as desired except for this peerid mixup that is happening on the sprites that get created on the peer side

But I thought sync object should always trigger whenever oncreated event happens and accordingly updating multiplayer.peerid with whoever created it...strangely it only works for the very first instance and not for others!!
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Wed Oct 22, 2014 4:05 am

kmsravindra wrote:Strangely it only works for the very first instance and not for others!!

I came into conclusion that the data arrived in parallel ordered (independent) not in serial ordered (dependent) (I dont know the right word for it), because I found in my spam test, some sprites changed color but some don't, event upon creation all should change the color on created, it's inconsistent. However it's an old test, I'm not sure whether I myself made a mistake on the event, but when the wait for signal works, I think that is the case.
B
28
S
8
G
4
Posts: 553
Reputation: 4,914

Post » Wed Oct 22, 2014 7:02 am

Thanks @DuckfaceNinja...I was able to make it work using "system wait signal action" !! So your reasoning is ofcourse correct...However this was a very convoluted approach....Not sure if this is the only way to approach this issue but I sincerely believe @Ashley finds a better MP plugin-built-in technique to circumvent this issue...
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Wed Jan 21, 2015 11:09 pm

Hi, I am encountering the same problem as kmsravindra, has a more elegant solution been found than "system wait signal action?"

Update:
GenkiGenga was able to fix this in my case, see topic 876478
B
7
Posts: 33
Reputation: 351

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests