Collisions and Synchronizing

Options
I used this code to sync the characters:

using UnityEngine;
using System.Collections;

public class CharacterNetwork2 : Photon.MonoBehaviour {

void Start () {

}

void Update() {

}

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
Vector3 pos = transform.position;
stream.Serialize(ref pos);
}
else
{
Vector3 receivedPosition = Vector3.zero;
stream.Serialize(ref receivedPosition);
transform.position = receivedPosition;
}
}
}

Basically right now its just controlling a cube in the third person.
(The players are rigidbodies)
The synchronization works fine, the players can see each other's movements and it updates regularly. Except if I control player A and push player B, player B is moved when viewing player A's screen, but when I look at the the screen of player B, it hasn't moved at all. Then I look back at player A's screen and player B has moved back to where it was before it was pushed.

I want it so that players can push each other around but I'm not sure how to fix this.

Comments

  • i have the same problem, i know it is because you are running two different unity's.
    I am also trying alll kind of things, also working but addforce, but i can't seem to get it working.
  • Tobias
    Options
    Try to work through the Marco Polo Tutorial again. This is most likely just a smallish mis-configuration but the setup of this isn't really complicated.
    http://doc.exitgames.com/photon-cloud/M ... o_Tutorial

    If you worked through this and couldn't solve your problem when you try again, let me know.
    Thanks.
  • chocomurr
    Options
    I tried that script first and got the same results, that's why I tried the other one from http://www.palladiumgames.net/tutorials ... -tutorial/. I want to know if there's some easy fix to this before I have to do something complex.
  • Tobias
    Options
    This is not an easy task. Due to lag, it's not simple to push networked objects around. Imagine 3 players push each other around wildly. They all send conflicting push messages around but those will not arrive at the same time on all clients. So one client gets pushed by 2 users, another just by one, later by another. If these things don't happen at the same time, they end up in different situations. And we simply can't guarantee that RPCs or updates will arrive everywhere at the same time.

    I fear you have to do something complex to solve this for your game.