Following tutorial, can't find next scene?
Options
Passengr
✭
in Photon Bolt
I'm following the first tutorial and when I try to make a server, it gives the error: "Exceptiont thrown while trying to find index of scene 'Tutorial1'". I've made sure that the next scene is in the build settings and that the name is correct in both the editor and the Menu script.
What am I doing wrong?
What am I doing wrong?
0
Comments
-
Edit, never mind still broken.0
-
In your PlayerCallbacks,ServerCallbacks, and/or ClientCallbacks do you have?
[BoltGlobalBehaviour("YOURLEVELNAME")]
public class YourCallbacks: Bolt.GlobalEventListener {}
or
// both server & client
[BoltGlobalBehaviour]
public class YourCallbacks: Bolt.GlobalEventListener {}
// only on the server
[BoltGlobalBehaviour(BoltNetworkModes.Server)]
// only on the client
[BoltGlobalBehaviour(BoltNetworkModes.Client)]
https://doc.photonengine.com/en/bolt/current/advanced-tutorials/chapter-20 -
Those callbacks aren't covered until the next part. The only callback used at the moment is the NetworkCallbacks which uses the [BoltGlobalBehaviour].
There are only two scripts used in the first part.
The call back:using UnityEngine; using System.Collections; [BoltGlobalBehaviour] public class NetworkCallbacks : Bolt.GlobalEventListener { public override void SceneLoadLocalDone(string map) { // randomize a position var pos = new Vector3(Random.Range(-16, 16), 0, Random.Range(-16, 16)); // instantiate cube BoltNetwork.Instantiate(BoltPrefabs.Cube, pos, Quaternion.identity); } }
The menu:using UnityEngine; using System.Collections; public class MenuTut : MonoBehaviour { void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START SERVER BoltLauncher.StartServer(UdpKit.UdpEndPoint.Parse("192.168.1.2:27000")); BoltNetwork.LoadScene("Tutorial1"); } if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START CLIENT BoltLauncher.StartClient(); BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse("192.168.1.2:27000")); } GUILayout.EndArea(); } }
It's pretty much copy paste from the tutorial.0 -
Make sure you have compiled Bolt Assemblies and updated the bolt prefab database. I believe that was reason I got those errors first time I tried doing the tutorials.0
-
Hi Passengr,
I was stuck there my self and after some research I found that the tutorial is outdated.
The scripts should look as follow:
Menu:using UnityEngine; using System.Collections; public class MenuTut : MonoBehaviour { void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START SERVER BoltLauncher.StartServer(UdpKit.UdpEndPoint.Parse("127.0.0.1:27000")); } if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { // START CLIENT BoltLauncher.StartClient(); } GUILayout.EndArea(); } }
The call back:using UnityEngine; using System.Collections; [BoltGlobalBehaviour] public class NetworkCallbacks : Bolt.GlobalEventListener { public override void BoltStartDone() { if (BoltNetwork.isServer) { BoltNetwork.LoadScene("Tutorial1"); } else { BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse("127.0.0.1:27000")); } } public override void SceneLoadLocalDone(string map) { var pos = new Vector3(Random.Range(-10,10),0,Random.Range(-10,10)); //instantiate cube BoltNetwork.Instantiate(BoltPrefabs.Cube, pos, Quaternion.identity); } }
-1 -
Hello Everyone,
I was stuck in this problem before and solved it now.
In my case, the problem is that I have two prefabs in same name "Cube", if you was following the tutorial. The reason of name conflict was that the imported "Photon Bolt Sample" package also was containing asset "Cube". Then, once you clicked "Update Prefab Database", errors might throw out and interrupted the scenes update.
Just change your cube name to whatever other name your like and recompile, problem should be solved.
Sorry for my bad English.0