Photon / Networking Multiple players, Multiple moving platforms

Driving me mad!

Issue
The game has multiple moving platforms that players are “teamed” together on. E.g. Red team on one platform, Blue team on another. Players can spawn on either team, and when the platforms are not moving, the networking works fine. A player can then request to take over control of the platform and can move their own teams platform around.

If two players are on the same platform, when the platform is moved, the ‘remote’ players stutter around and jump - because the platform is moving, but the Lerping of the remote position is not quite correct. The players are not parented to anything, which could be a solution - but the players should be able to move from their own platform to the other, which makes it even more tricky to accomplish.

Possible Solutions

  • One solution is to use some sort of clever network extrapolation to smooth out the position of the players, relative to the platform that they are one. I’m not sure if this would work very well though.
  • Parent each player to their respective platform - this should solve the stuttering of players on the same platform, but then the players on the other platform will have issues. If the player moves from one platform to the other, simply change the parent. Not sure if this can be done seamlessly.
  • Maybe there is a more obvious solution I am missing?
  • Give up and become a bin man?

I’m not looking for someone to write a whole system obviously, but any help would be appreciated.

Each player has the following simple network smoothing :

// Update is called once per frame
	void Update()
	{
		if (!photonView.isMine) {
						transform.position = Vector3.Lerp (transform.position, this.correctPlayerPos, Time.deltaTime * 8);
						transform.rotation = Quaternion.Lerp (transform.rotation, this.correctPlayerRot, Time.deltaTime * 8);
		} 

	}

	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{

		if (stream.isWriting)
		{
			// We own this player: send the others our data
			stream.SendNext(transform.position);
			stream.SendNext(transform.rotation);
			
		}
		else
		{
			// Network player, receive data
			this.correctPlayerPos = (Vector3)stream.ReceiveNext();
			this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
		}
	}

Thanks in advance!

You could child the players to a platform and send the local position instead of the global position. Then you use the same smoothing technique except on transform.localPosition. If you want to change platforms, simply detach the child on OnCollisionExit and attach to child to the new platform on OnCollisionEnter.