Synchronization Issue?

Options
Hello, I am unsure of what is causing my current predicament and I'm hoping someone here can shed some light.

In unity I run a heavily scripted simulation for two players using the Photon network. One player is in a boat travelling down a river to a waterfall, while another player is in a helicopter sent to rescue him.

I instantiate both the helicopter and boat prefabs like so:

[code2=csharp]void OnJoinedRoom()
{
if (PhotonNetwork.room.playerCount == 1) {
Transform spawn_point = GameObject.Find("heli_spawn_point").transform;
heli = PhotonNetwork.Instantiate("heli2", spawn_point.position, spawn_point.rotation, 0);
heli.GetComponentInChildren<OVRCameraController>().SetEnabled(true);
//heli.GetComponentInChildren<AudioListener>().enabled = true;
} else {
Transform spawn_point = GameObject.Find("boat_spawn_point").transform;
boat = PhotonNetwork.Instantiate("boat", spawn_point.position, spawn_point.rotation, 0);
boat.GetComponentInChildren<CharacterController>().enabled = true;
boat.GetComponentInChildren<OVRCameraController>().SetEnabled(true);
//boat.GetComponentInChildren<AudioListener>().enabled = true;
}
}[/code2]

And when both players are in the game, an on rails event takes place where the helicopter saves the player before he falls.

My main issue is that I tried to add player interaction to it. All I want is that when you press the assigned key and are within saving distance, the saving animation will take place.

[code2=csharp]if (Input.GetKeyDown (KeyCode.Space) == true && saveable)
{

//removes both heli from being children of boat
//rotate heli back to hovering properly
saved = true;
heli.transform.parent = null;
transform.parent = null;
}[/code2]

It functions in a single-player environment just fine. When the boat collides with a checkpoint, the helicopter becomes a child of the boat and follows it down the river and when the player presses the input key, both the player and the heli stop being children of the boat and the player moves toward the helicopter.

This works fine on one client, where the player touches the heli and the heli stays in place while the boat sails away, but on the other client where you are the pilot, it hasn't updated and is still following the boat. It follows the boat for a good while, stopping further down the river. eventually, on the boater client, the helicopter teleports to the location from the pilot client and causes some serious issues.

Both clients seem to recognize the collision at the same time because all script calls and events revolving around colliding into a checkpoint happen at the same time on each client. But when input becomes involved, there seems to be an issue. How can I fix this?

Any help would be appreciated, thank you.

Comments

  • Tobias
    Options
    Sending the input around will cause some delay. A few 100ms you can't avoid fully.
    Is the problem you can't send the key (success or not) across or what is the cause for the problem?
    If you synced the "key was pressed in time" event successfully, you should be able to trigger the animation on all connected clients, too.
    You might want to disable positional syncing while you do the animation (either way). As you have the animation, you don't really need to sync positions anymore.