GNet sync problems

BlitzMax Forums/BlitzMax Programming/GNet sync problems

Arska(Posted 2012) [#1]
What is best way to only sync variables if it's other player?

Now when "GNET_CREATED", i create player model and when "GNET_MODIFIED" then i place models in right positions. Problem is that it creates model for local player too and when 2 players are connected player models are flickering because models changes their places all the time.

I tried to make local variable "myPlayerID = -1" and then i only position models if "myPlayerID <> p.playerID", but no luck.

I'll give some code later if needed.


Arska(Posted 2012) [#2]
Really? Nobody?

If Not nickName = pa.nickname Then
		positionentity(pa.model, vec3(pa.playerX, pa.playerY, pa.playerZ))
		rotateentity(pa.model, vec3(pa.playerRX, pa.playerRY-180, pa.playerRZ))		
		
		positionentity(pa.flashlightL, vec3(pa.playerX, pa.playerY, pa.playerZ))
		rotateentity(pa.flashlightL, vec3(pa.playerRX, pa.playerRY, pa.playerRZ))
EndIf


pa.nickname is all nicknames which are from server.

So why it's not working? I tried only position player in place if nickname is not my own. Without that "if", player models are positioning player to another.


matibee(Posted 2012) [#3]
Sorry Arska. It's not that the few of us still visiting here regularly aren't listening, I'm sure we are. But the chances of finding someone familiar with GNet looks slim.

Why not write a little demo that you can post here, for anyone to copy+paste+run (ie no assets required), and I'm sure we'll have a poke around with it and help if we can.

Good luck.


Arska(Posted 2012) [#4]
Alright. I will make some kind of demo, but first i give you my "multiplayer.bmx" part of the code if it helps. This code includes everything about GNet and multiplayer.

Pastebin link:
http://paste.servut.us/plain/r3d0

I'am getting really frustrated because everything else is working fine and this problem slows down my project.

Please tell me if demo is needed to solve this. I will make it.


matibee(Posted 2012) [#5]
I don't know GNet but comparing your code to the sample.

Why are you registering your gnet synced variables repeatedly?

The demo goes...

register variables

main loop
{
   get updates
   do stuff
}



Arska(Posted 2012) [#6]
What you mean about registering synced variables repeatedly?

This is made just same way as i did:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1640


matibee(Posted 2012) [#7]
Ok, that's not what I thought it was. Try looking at the sample game though.. [blitzmax install path]/samples/mak/gnetdemo.bmx


Arska(Posted 2012) [#8]
OMG! I got it working. Thanks for your help Matibee. :)

What i did was i updated gnet variables if GNetObjectRemote( obj ) and then i only change model positions if nickName <> pa.nickname.

Last edited 2012


Arska(Posted 2012) [#9]
So it works good with 2 players, but when third one joins, flickering continues between 2 remote players. Any ideas to fix this?


Arska(Posted 2012) [#10]
So i'll bumb my topic little bit for last time, if somebody would notice it and help me out.

I think i know what is wrong, but i can't come up with any solution to fix it.

So now program knows who is local object and who is remote, but when there is 2 remote objects it thinks those are same... I really really appreciate any help you can give me. I am so out of ideas in this one. :/

I don't even know is the problem in my dedicated server or client side.


Arska(Posted 2012) [#11]
Made some more research and here is more info.

So problem can be server side too. Here is Dedicated server code:
http://paste.servut.us/plain/gu4s


Here is some server log:

Player Arska134(0) has joined the game!
Players on server: 1
Player test(1) has joined the game!
Players on server: 2
Player test(0) has disconnected!
Players on server: 1
Player test2(2) has joined the game!
Players on server: 2
Player Arska134(0) has disconnected!
Players on server: 1
Player test2(0) has disconnected!
Players on server: 0



As you can see between brackets is player ID and that is different when disconnecting.


Arska(Posted 2012) [#12]
Alright this case is closed.

I don't know why i didn't solve this long time ago. Solution was simple:
If p.nickName = GetGNetString( remoteObj, 1) Then


Last edited 2012