Help Multiplayer Object Instance Varible

Get help using Construct 2

Post » Sat Feb 14, 2015 5:29 pm

I am making this multiplayer demo to learn how to program multiplayer games.
The problem I am having is with the main sync object(tank). When a new player joins the game the computer will make sync object(tank) for all the other players already in the game. They show up in the right position and angle on the screen but all the instance varibles are set to their default state.

How do I get all the other players Object(tank) instance varibles to sync up with the new joining player?
My object(tank) has instance varibles like health,kills,deaths,speed and weapon that need to get sync up.

I think the problem might be in my signalling group. I have tried playing around with it but nothing I've had tried seemed to work.

You can play with what I have done so far here:
https://dl.dropboxusercontent.com/u/1244375/Multiplayer%20Tank%20game%20example/index.html
I will also upload the cap file so you can check it out.
https://dl.dropboxusercontent.com/u/1244375/MultiplayerTank22.capx
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Feb 16, 2015 12:47 pm

One way would be to have the host determine their values.

Use sync variable and leave the client tag empty "" and do not add a client input value tag.
This will force the value of the var to be the same as the host vars :)

Now its just a matter of informing the host of what your value is :) (sent message with info to host, host sets variable based on that)
Who dares wins
B
56
S
15
G
16
Posts: 1,837
Reputation: 16,775

Post » Mon Feb 16, 2015 1:06 pm

Thanks lennaert for the tips :) .
I was playing with you in your multiplayer tank game Sunday. The game is looking great.
Wish I could get a look at a early ver of your cap file so I could study how the multiplayer (Signalling, Host, Peer and Common Groups) all work together. LOL I am having a problem getting my head around the logic of multiplayer coding.
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Feb 16, 2015 1:44 pm

Multiplayer is actually easier then it appears, one quickly can get lost on who is telling who what to do ..... (I did lots of times :P)

Signalling (not signal server) is actually just a small part, its the same as sending a message to all peers and have them set a state as the host sets it himself.

Lots of times when I made a bug, it was because I was having actions performed twice due to sending info around too much.

keep in mind:

peer sent message to host to be broadcasted to all: perform action on peer, sent message to host
host receives message from peer to relay to all: host performs action (same as peer just did) and sents a broadcast with information to all peers
all peers (NOT! the original sender) : should receive the message and perform needed actions the original sender and host just did.

Effectively, 1 action is performed 3 times. You, host and all other peers (not host and not you, because those 2 already did it)

This process is about the same for every other aspect in a multiplayer game where you want a peers action/setting to be synched with all outside of the sync var functionality.

Now with a bit of smart approaching, you can stuff near all general actions in 1 big for each peers loop in the common sheet, and have every body tell one another what their states are. Based on these states the loop performs needed actions for all the players (host and peers).


big tip:
when making sent and broadcast messages, becarefull with textuall content, also with their naming tags.

just imagine

Tag names:

"ThisIsABigTextActingAsTheTagTitleToSentInfoToPeers"

v.s.

"tp"


The tags are sent along too, the bigger/longer the names, the more data needs to be submitted, more overhead.

Or

message content:

tag: "PlayerDied"
message: "The player has died in a horrible way"

v.s.

tag: "pd"
message: "1"

event:
on peer message received "pd"
action
set text "player has died in a horrible way"


In the second example, the text is taken from the event sheet, in contrast to sending it along.

its like a couple K bytes vs several bytes.
Who dares wins
B
56
S
15
G
16
Posts: 1,837
Reputation: 16,775


Post » Mon Feb 16, 2015 2:25 pm

Microsoft is hosting another Construct2 Teaching Session. This time it is advanced game development which includes multiplayer scenarios.
Register for free here

Find out how to include privacy and support settings, and even add a leaderboard. Work with multiplayer scenarios, advertising, in-app purchases, and much more


Looks like fun.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,698

Post » Mon Feb 16, 2015 2:50 pm

@dutoit that sounds amazing! Try for the heads up, if I can attend I will, considering the multiplayer is my senior capstone, heh.

Also @lennaert thanks again for some of your tips on multiplayer. :D
ImageImageImageImage
B
56
S
19
G
51
Posts: 633
Reputation: 30,656

Post » Mon Feb 16, 2015 4:01 pm

Thanks @dutoit for the heads up on that :)

@Lordshiva1948, yes I have been reading those tutorials over and over lol
B
15
S
10
G
8
Posts: 107
Reputation: 4,944

Post » Mon Feb 16, 2015 7:46 pm

@DatapawWolf - if you miss it, like I always do, due to timezones. They are pretty good at having the videos/course materials up a day or 2 after.

@Maxum, the last course was very good... it was beginner, but had some nuggets in it. This is going to be pure gold ;)

@lennaert, as always, great fedback.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,698


Return to How do I....?

Who is online

Users browsing this forum: matrixreal, Phacanu, the_Shit_hawk and 10 guests