diff --git a/Assets/NetworkManagerRocket.cs b/Assets/NetworkManagerRocket.cs index 4f70120..096cd80 100644 --- a/Assets/NetworkManagerRocket.cs +++ b/Assets/NetworkManagerRocket.cs @@ -43,6 +43,17 @@ void SwitchScenes() preparing = false; } + void StopMusic() + { + RocketSphere[] players = FindObjectsOfType(); + + for (int i = 0; i < players.Length; i++) + { + // deactivate music all the ships on all clients + players[i].RpcStopMusic(); + } + } + void Update() { if (RockSphere.count != lastCount) @@ -58,8 +69,7 @@ void Update() preparing = true; - // stop the music at the end of the level - Camera.main.transform.gameObject.GetComponent().Stop(); + StopMusic(); // wait 10 seconds before switching to the next level Invoke("SwitchScenes", 10); diff --git a/Assets/RocketSphere.cs b/Assets/RocketSphere.cs index 1648300..74d6318 100644 --- a/Assets/RocketSphere.cs +++ b/Assets/RocketSphere.cs @@ -7,7 +7,6 @@ //ideas // fixed wormhole between two depth levels // hyperspace between two depth levels -// multi-player // shield, use physics to bounce off rocks and other ships // UFO // radar circle indicating rocks, UFOs, enemy rockets around @@ -15,6 +14,7 @@ // make front transparent when in background // bright light shots with lens flare // readjust center point if head moves too far away from center +// add fade in and out of levels //rockets, rocks and ray-guns // stick man astronauts @@ -24,8 +24,6 @@ // laser instead of shots will cut rocks om half instead of break them up in two. // need to scale speed (ship and shot and rocks) by radius otherwise the outer layers get really fast -// When disconnecting from the server before leaving all clients generate a hyperspace sound to indicate you are leaving - public class RocketSphere : NetworkBehaviour { GameObject rocket; @@ -55,7 +53,7 @@ void OnDestroy() { Destroy(cachedMaterial); } - + public override void OnStartServer() { // call the base function, important, odd behavior when connecting when not on same start scene @@ -110,7 +108,10 @@ public override void OnStartServer() // Use this for initialization void Start() { - + // mirror does not garentee that start functions will be called in the same order on the server and client and when a client connects + // if (isServer) and if (isClient) are not sufficient controls + // move all start functions to OnStartClient() or OnStartServer(), + // be sure to call the base function or you will not get proper function when switching scenes and connecting } public override void OnStartClient() @@ -210,6 +211,13 @@ void MySetActive(bool active, Quaternion rotation, bool playhyperspace) } } + [ClientRpc] + public void RpcStopMusic() + { + // stop the music at the end of the level + Camera.main.transform.gameObject.GetComponent().Stop(); + } + [ClientRpc] public void RpcMySetActive(bool active, Quaternion rotation, bool playhyperspace) { @@ -262,6 +270,9 @@ void OnTriggerEnter(Collider other) } // we only shoot on the server + // clients control rockets but server controls shots, + // there is a bit of a delay difference and can result in client player rockets running into their own shots at high speed + // need to find a solution to this issue, moving the shot out further is not pretty [Server] void Fire() { @@ -454,6 +465,5 @@ void Update() { } - } } \ No newline at end of file diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 4794c37..9861984 100644 Binary files a/ProjectSettings/GraphicsSettings.asset and b/ProjectSettings/GraphicsSettings.asset differ diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 3b68d66..bad43c0 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ