playMaker

Author Topic: PHOTON synchronizing problem. Cars are lagging alot.  (Read 22803 times)

bizilux

  • Full Member
  • ***
  • Posts: 171
PHOTON synchronizing problem. Cars are lagging alot.
« on: November 05, 2013, 06:57:34 PM »
hey guys...

so i've been fooling around with photon for couple of hours, trying to make this work... and i finally pulled it off, but the problem is that it looks laggy, and out of synchronization and basically not smooth...

basically its a racing game, so there will be cars, so i have 2 instances opened, and 2 cars there... just watch the video and look for urself that it is not smooth...

Not a valid vimeo URL
oh and im using edy's vehicle physics asset, and FSM's that i have on car are basically copy-paste of "Fsm Photon player" that comes with DemoWorker example. i've just removed animation FSM, because i dont have any anymations...



you can see that physics of collisions are really f*cked up... in singleplayer if i have 2 cars they collide like they should, and basically if you ram one car against second car, the second car will get pushed away, etc... but when in multiplayer, this isnt the case as you can see...

is it because edy's vehicle physics asset? or am i doing something wrong


one thing to note: at 0:25, when i go out of the game and in again, you can see player count is at 3 somehow, but i only had 2 instances opened... you think theres problem here?
its the same at 1:08 when i respawn another instance
« Last Edit: November 05, 2013, 07:01:45 PM by bizilux »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #1 on: November 05, 2013, 07:08:33 PM »
With regards to the juddering, it might be the same problem that I encountered:
http://hutonggames.com/playmakerforum/index.php?topic=5126

To narrow it down, I basically assigned a Player # via a global bool, and then on each Character (1-4) on the controls FSM I put in a check for the Player # global bool and only allowed the correct player to control each character.

You might want to throw in something like that temporarily to see if it's the control from the other player's instance that's causing the judder.

My experience with Photon was an absolute nightmare, it took far longer so get things working initially than I imagined, and even when changing tiny things it tends to fall apart.

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #2 on: November 05, 2013, 07:36:27 PM »
yes... it might be the problem with somehow not disabling all control scripts...

basically im in bit of a pickle... because this edy's vehicle physics is huge... and contains lots of scripts, i think im gonna have to ask owner for help here... 
its not like the demo where you just disable character controller and thats it :(


the thing is, when i play singpleplayer, controls are 100% disabled if i want them to be...
basically there is 1 boolean in "car control" script called, "Read User Input" and if its off, in singleplayer that car remains totally still and not receiving any inputs from keys... so im just really surprised that it could be this... because it just works in singleplayer


i dont really understand how you solved that problem, ur saying you assigned Player ID to players? but then you say you did it with global boolean? thats true/false?


photon is been a nightmare for me too... its got really high learning curve, its complex stuff... but yeh thats to be expected for multiplayer... multiplayer after-all is a rocket science to write from scratch.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #3 on: November 05, 2013, 07:45:21 PM »
Yep, I created 4 buttons on my front end menu screen - P1-P4, and when clicked, they set a global bool - e.g. "Player1" = True. Then after setting up the room and loading into it, on the Player 1 Character gameobject's Player Control FSM, I added a 'bool test' state at the top (so it's tested from the Start transition) to check for Player 1 = True.  If that's true, then allow the rest of the controls to be used.

And the same for the Player 2 menu button / Character gameobject / controls FSM.

It basically ensured that ONLY the one and correct player could control each character. In theory it should have been possible with the 'ismine' stuff on the Photon FSMs, but it just didn't work - I'd always get other players affecting each other slightly, which created the juddering.

Edit: Oh, and to make that work, I duplicated my player character so I had 4 seperate ones (rather than instantiating from the same game object), but that makes sense later anyway as I'll be having 4 visually different characters with different abilities.
« Last Edit: November 05, 2013, 07:49:57 PM by jess84 »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #4 on: November 05, 2013, 08:19:55 PM »
Quote
Edit: Oh, and to make that work, I duplicated my player character so I had 4 seperate ones (rather than instantiating from the same game object), but that makes sense later anyway as I'll be having 4 visually different characters with different abilities.

ye i was thinking about that last part... because your system wouldnt work with Photon Instantiate action that im using right now...

i'll try to do that and we will see if it will work...

oh 1 more question: did you remove all FSM's on players? you only had photon view and proxy on player?  or did you just remove behavior FSM and let position sync FSM and rotation sync FSM and variable sync repository FSM in there?

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #5 on: November 05, 2013, 08:29:22 PM »
As I said, it wouldn't be ideal long term, but it might help you identify the problem.  (It wouldn't take long to temporarily modify your Photon Network Instantiate target)


These are the ones I have left, and everything works for me. (I basically copied most from the DemoWorker character and modified as needed)

Animation Sync
GameObject Naming
Position Sync
Rotation Sync
Variable Sync Repository
Photon Network Sync
My controls FsM
Playmaker Photon Game Object Proxy
PhotonView

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #6 on: November 05, 2013, 08:45:27 PM »
Quote
As I said, it wouldn't be ideal long term, but it might help you identify the problem.  (It wouldn't take long to temporarily modify your Photon Network Instantiate target)

oh yes thats not a problem, i will just place 2 cars in scene instead of using initiate action... i was just wondering if you did it in that way

oh 1 more stupid question :)

i noticed you have Photon Network Sync there... i know this is auto created if you use photon setup wizard. but what do you have in that FSM?

i thought Variable Sync Repository from DemoWorker example, is just a renamed FSM for Photon Network Sync... is that not the case? :/

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #7 on: November 05, 2013, 09:05:15 PM »
I think it is. The Photon Network Sync FSM on mine is empty. I should probably delete it, but I've found that deleting even the most deletable things has unexpected consequences  :)

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #8 on: November 05, 2013, 10:16:06 PM »
well i tried it... photon doesnt like me at all...

just feeling delightful when the core mechanics of the game is not working...  game will only be multiplayer and i cant figure that photon thing... ah what a bummer...

basically i've put 2 buttons in game, and 2 cars in game, 1 button enables "Read User Input" for first car, and second button enables it on second car...

the thing is when i open 2 instances everything is ok, and when i click on button 1 to control car 1, on that instance it is ok, but on the second instance it is still choppy when turning...  going in a straight line kind of works OK, with a bit of delay on second instance... but turning, aka rotating... that has huge choppiness to it... :/

and when i click on button 2 on second instance... then things really go all weird with glitching and stuff, the car just wont move and it just sort of freezes in that place, going back and forth a bit...

i dont know... i guess i'll try tomorrow with "Fsm Photon player" from demoworker example, instead of cars... and see how that turns out... but yeh i think that will work just fine, its something to do with cars... so complicating :/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #9 on: November 06, 2013, 12:57:22 AM »
Hi,

 Yes, start with a simple "player" dummy to make sure your photon routines are working.

 I think you are facing two issues, photon setup and multi player physics games... I think you should ask for guidance on the Photon forum on how to set up a a physics bases racing game, I am not sure myself how to achieve a decent multi player physics dependant world, it might require a proper server running a headless Unity version of your game that centralize all inputs and compute the physics only here, making all other running instances slaved.

but there might be a simpler approach.

Bye,

 Jean

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #10 on: November 06, 2013, 11:48:21 AM »
well im in deep shit when even Jean doesnt know how to solve this issue... and you are Photon God, compared to me :) im just little Peasant who picks up potatoes and carrots on his little farm lol :D

i tested it with demoworker prefabs and its working... so yeh i'll try asking on photon forum and report back here...

and also... i made "work in progress" thread here, you can play current singleplayer version
http://hutonggames.com/playmakerforum/index.php?topic=5404.0

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #11 on: November 08, 2013, 01:59:27 AM »
Hi,

 you should definitly gather as much info and consulting on this from various places, it's been done before, so it must be feasible, but at what cost in terms of server knowledge and expertize, that's the catch...


bye,

 Jean

drakuls

  • Playmaker Newbie
  • *
  • Posts: 3
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #12 on: December 02, 2013, 04:15:55 AM »
Hi!
I am also developing game with Photon. I have a question did you managed to get the wheels to stear and spin - so the other players can see other drivers car wheels stearing and spinning ?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #13 on: December 02, 2013, 04:51:28 AM »
Hi,

 To do this, you need a two stage synchronization, at least this is how I would experiment with this:

-- synchronize user input, so that you control the wheel collider exactly the same
-- synchronize gameobject position, so that you avoid drifting of the gameobject real location because of the user input synchronization latency.

 the other way to do this, is to have fakes wheels on the slaved instance that matches the wheels from the master, then you don't need to control the wheel collider per say, but simply visually show it with just the wheel mesh.

bye,

 Jean

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: PHOTON synchronizing problem. Cars are lagging alot.
« Reply #14 on: December 02, 2013, 11:46:20 AM »
hey guys, a small update...

we are now a team of 5 people, and we actually switched to uLink library... its much better than photon, when it comes to physics... because photon is just not made for such things...