Scene Breaks In Editor Only But Works In Build

Hello, when ever I load into my multiplayer scene my camera doesn't attach to my player and I get these errors:

Code:
Error: Unable to find the character with the Player tag. The camera will be disabled.
UnityEngine.Debug:LogError(Object)
Opsive.UltimateCharacterController.Camera.CameraController:Awake() (at Assets/Opsive/UltimateCharacterController/Scripts/Camera/CameraController.cs:198)

Code:
IndexOutOfRangeException: Index was outside the bounds of the array.
Opsive.UltimateCharacterController.Demo.DemoManager.SelectStartingPerspective (System.Boolean firstPersonPerspective, System.Boolean teleport) (at Assets/Opsive/UltimateCharacterController/Demo/Scripts/DemoManager.cs:415)
Opsive.UltimateCharacterController.Demo.DemoManager.InitializeCharacter (UnityEngine.GameObject character, System.Boolean selectStartingPerspective, System.Boolean teleport) (at Assets/Opsive/UltimateCharacterController/Demo/Scripts/DemoManager.cs:266)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Demo.PunDemoManager.OnPlayerEnteredRoom (Photon.Realtime.Player player, UnityEngine.GameObject character) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Demo/Scripts/PunDemoManager.cs:45)
Opsive.Shared.Events.InvokableAction`2[T1,T2].Invoke (T1 arg1, T2 arg2) (at <e15a7b5bc24b42cc9555a0786a0e2f0f>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1,T2] (System.String eventName, T1 arg1, T2 arg2) (at <e15a7b5bc24b42cc9555a0786a0e2f0f>:0)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.SpawnPlayer (Photon.Realtime.Player newPlayer) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/SpawnManagerBase.cs:174)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.Start () (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/SpawnManagerBase.cs:93)

Code:
Error: There is no look source attached to the character. Ensure the character has a look source attached. For player characters the look source is the Camera Controller, and AI agents use the Local Look Source.
UnityEngine.Debug:LogError(Object)
Opsive.UltimateCharacterController.FirstPersonController.Character.MovementTypes.Combat:GetDeltaYawRotation(Single, Single, Single, Single) (at Assets/Opsive/UltimateCharacterController/Scripts/FirstPersonController/Character/MovementTypes/Combat.cs:32)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler:GetDeltaYawRotation() (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:196)
Opsive.UltimateCharacterController.Game.KinematicCharacter:Move(Boolean) (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:224)
Opsive.UltimateCharacterController.Game.KinematicObjectManager:FixedUpdate() (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:844)

Code:
NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.PhotonView.ResetOwnership () (at Assets/Core/Photon/PhotonUnityNetworking/Code/PhotonView.cs:298)
Photon.Pun.PhotonView.ResetPhotonView (System.Boolean resetOwner) (at Assets/Core/Photon/PhotonUnityNetworking/Code/PhotonView.cs:282)
Photon.Pun.PhotonNetwork.LocalCleanupAnythingInstantiated (System.Boolean destroyInstantiatedGameObjects) (at Assets/Core/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:293)
Photon.Pun.PhotonHandler.OnLeftRoom () (at Assets/Core/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:287)
Photon.Realtime.MatchMakingCallbacksContainer.OnLeftRoom () (at Assets/Core/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3969)
Photon.Realtime.LoadBalancingClient.OnStatusChanged (ExitGames.Client.Photon.StatusCode statusCode) (at Assets/Core/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2846)
ExitGames.Client.Photon.PeerBase+<>c__DisplayClass110_0.<EnqueueStatusCallback>b__0 () (at <a497a6f18e1f4b419421b940add27a6e>:0)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <a497a6f18e1f4b419421b940add27a6e>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <a497a6f18e1f4b419421b940add27a6e>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Core/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:208)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Core/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:142)

I have no idea why these are happening as my player does have the "Player" tag and I disabled the demo manager. Everything works fine in build so I'm stumped.
 
Are you running the most recent version? Can you tell me how to reproduce it within the demo scene of a fresh project?
 
Yes I am running the lastest version. Other than my scripts the only diffrent thing in the scene is that the Demo Manager is disabled.
 
The Demo Manager sets the camera so that's likely the cause. If you aren't using the Demo Manager then you'll need to set the camera yourself.
 
You can set the character by getting a reference to the CameraController and then setting the Character property.
 
You can set the character by getting a reference to the CameraController and then setting the Character property.

So I found out that Pun Demo Manager is still active even when its disabled in the inspector so that's not the issue. I have forced the camera controller to actually bind the the player using Start() instead of Awake() now the camera controller no longer tells me it can't find the player. But now i'm getting this error:

Code:
IndexOutOfRangeException: Index was outside the bounds of the array.
Opsive.UltimateCharacterController.Demo.DemoManager.SelectStartingPerspective (System.Boolean firstPersonPerspective, System.Boolean teleport) (at Assets/Opsive/UltimateCharacterController/Demo/Scripts/DemoManager.cs:415)
Opsive.UltimateCharacterController.Demo.DemoManager.InitializeCharacter (UnityEngine.GameObject character, System.Boolean selectStartingPerspective, System.Boolean teleport) (at Assets/Opsive/UltimateCharacterController/Demo/Scripts/DemoManager.cs:266)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Demo.PunDemoManager.OnPlayerEnteredRoom (Photon.Realtime.Player player, UnityEngine.GameObject character) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Demo/Scripts/PunDemoManager.cs:45)
Opsive.Shared.Events.InvokableAction`2[T1,T2].Invoke (T1 arg1, T2 arg2) (at <e15a7b5bc24b42cc9555a0786a0e2f0f>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1,T2] (System.String eventName, T1 arg1, T2 arg2) (at <e15a7b5bc24b42cc9555a0786a0e2f0f>:0)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.SpawnPlayer (Photon.Realtime.Player newPlayer) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/SpawnManagerBase.cs:174)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.Start () (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/SpawnManagerBase.cs:93)

This might be due to the fact that the perspective isn't set. How can I force first person perspective?
 
You should not be using the DemoManager within your own scene. The DemoManager is setup in a very specific way just for that scene so you'll have problems adopting it for your own scene.
 
You should not be using the DemoManager within your own scene. The DemoManager is setup in a very specific way just for that scene so you'll have problems adopting it for your own scene.
After deleting the Demo Manager now Its saying that there is no player to assign to the camera even though it gets assigned. Also now my first person objects are hidden the moment I load in.
 
Last edited:
The First Person Objects component manages the visibility. I would start with a new project and follow these videos from a fresh scene: https://opsive.com/videos/?pid=1110

Why does removing the demo manager cause the First Person Objects Gameobject to be inactive? I've noticed that removing demo manager messing everything up so ive reverted to a previous version with it still in the scene and reverted my camera controller changes. Demo manger doesn't seem to due anything special so i'm not sure why this is all happening. Now I just want to solve the original problem.
 
Last edited:
There's a lot going on so it's really hard to say. I would follow the videos above within in a new scene - I don't use the Demo Manager and the arms appear.
 
There's a lot going on so it's really hard to say. I would follow the videos above within in a new scene - I don't use the Demo Manager and the arms appear.

Not getting any can't find player or camera isn't assigned errors anymore but for some reason the first person game objects get disabled at runtime and I don't know why i'm not getting warnings or anything now. The only way for it to work is for me to make another script and always set the gameobject active.
 
Last edited:
Top