The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Synchronize moving platform over network(jerkin on client)

2011-12-20 13:39:44

Hey, I made a multiplayer game where one of my players got control over a platform and can move it. This works fine. But when an other player, who is not the network owner(this is the first player joining the game, who can also control the platform), stands on the platform, the screen and platform "jerks"(i hope it is the right word to describe this behaviour, i'm not native englisch :D . An other word i found is "bucking"). I tried using physics and also transform.translate but its not working right. If i look with the "platform network owner" player to the other player he also isn't in its right position, where he is on his own screen. This error also happens only when the players stands on the platform. I hope someone can help me :) .


2011-12-21 10:47:50

Networking physics can be quite troublesome and needs to be thought out well. You have quite a few options here, however most important is that you need to be aware of what you are sending and who controls the movement.

Some options:

  • Don't network physics. This is probably not an option for you.
  • Authorative masterclient: Make ONLY the masterclient control the objects (and have the other clients smooth the received positions with the current position: use Lerp
  • Keep the solution as is, with different owners (or even multiple owner)..but make sure you apply smoothing. Dont set the positions directly but lerp towards the correct value: // Here correctVector3 is a Vector3 that you send/receive via OnSerializePhotonView transform.position = Vector3.Lerp(transform.position, correctVector3, Time.deltaTime);

2011-12-21 13:21:54

Hey Leepo, thanks for your answer :). I already lerp the position and rotation, but that doesnt work right. I'm currently not using physics(rigidbody), but transform.translate to move the platform. But the problem is still there. I tried a differend solution, now. I send rpcs to the other players, when the movement of the platform changes. This seems to work(no jerking), but maybe this does get to problems later? But also with this solution, the other players doesnt appear at the same position as they really are while the platform is moving. When the platform doesnt move they return to their real position(like it is on their own screen). If you don't exactly now where my problem is, i can also explain it in german(because i know that some of you are from germany, like myself :) ).

2011-12-22 14:11:21

Also when i join the game with a second player there is a "yellow" warning: "New player=False player: testst nr=2". This sounds as if the player can't join the game, but he can and nothing else happens, despite the warning. Somebody know what that means?

2012-02-29 12:52:26

EDIT: Solved it :)

I really don't know what else i could try to make this work. This is the network code i got currently in the project. It's very basic and just vor testing purposes(i use the photon network engine). My problem is that if two or more players stand on a moving platform, the other players you are looking at with your own player shake back and fourth violently and appear a little bit behind the position they are on their own screen. This only happens on a moving object, on a firm ground everything works fine. Your own player doesnt shake, so i think its a problem with the network code. I tried many different things but I dont get it to work and really got no idea what the problem could be. I also used other methods like the Character Motor + FpsInput controller for the movement of the players, but that doesnt changed anything. I also tried to stream the movement of the ship the same way like the players and not with rpcs and I also parented the players to the ship(like you can see in the code below). I further tried to move the ship with add.relative force instead of transform.Translate. But none of this solved the problem. In the current version no rigidbody is attached to the platform or the players.

Code on the players:

Code on the Platform:

Fps control script:

There are some german words in the code, but I hope it is clear. In the ship network code the button you push determines in which direction the platform moves(unten = up, links = left etc.). I hope someone can help me by reading the network code I posted :).

Back to top