Photon BOLT/multiple cameras issue

Croxo

New member
Hello,

I am using UFPS 2.0 and I have created the Nolan model and a first person camera.

So the Nolan character is a network object while the camera isn't.

Firstly, the camera doesn't attach to the character since the character doesn't spawn on awake, it spawns on the end of server loading.

Secondly, if I spawn the camera after the player spawning I get an issue where when the second player joins, the cameras detach from the players and are stationary. When the second player leaves the camera reattaches to the first player.
 
On the Camera Controller you should Init On Awake disabled and then set the character manually using the Character property:

 
On the Camera Controller you should Init On Awake disabled and then set the character manually using the Character property:


I fixed the attaching issue on start, but when a second player joins the Cameras both stay still(still shows they're attached in unity) and I can continue to move the characters and such but the camera stays frozen. The Camera reattaches upon the player 2 leaving the server.

Code:
lReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.FirstPersonController.Character.MovementTypes.Combat.GetDeltaYawRotation (System.Single characterHorizontalMovement, System.Single characterForwardMovement, System.Single cameraHorizontalMovement, System.Single cameraVerticalMovement) (at Assets/Opsive/UltimateCharacterController/Scripts/FirstPersonController/Character/MovementTypes/Combat.cs:28)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.GetDeltaYawRotation () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:196)
Opsive.UltimateCharacterController.Game.KinematicObjectManager+KinematicCharacter.FixedMove () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:179)
Opsive.UltimateCharacterController.Game.KinematicObjectManager.FixedUpdate () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:703)

I just keep getting this error, even though the object defined and set in the unity.

1117
 
That error indicates that a look source hasn't been added. The OnAttachLookSource should get called when the camera is attached. You can debug this by placing a breakpoint within MovementType.OnAttachLookSource.
 
That error indicates that a look source hasn't been added. The OnAttachLookSource should get called when the camera is attached. You can debug this by placing a breakpoint within MovementType.OnAttachLookSource.

Can I call InitializeCharacter from another script?
 
C#:
        m_character = BoltNetwork.Instantiate(BoltPrefabs.Nolan, spawnPosition, Quaternion.identity);
        var cameraController = camera.GetComponent<CameraController>();
        cameraController.InitializeCharacter(m_character);

This is my current code called everytime a player connects to the server. The camera is a client side object and the player is a network object. It stops working when more than 1 player is connected to the server.
 
You shouldn't call Initialize Character - instead you'll want to set the Character property directly. I am working on a PUN integration and with that I do something similar and it has been working well for me.
 
You shouldn't call Initialize Character - instead you'll want to set the Character property directly. I am working on a PUN integration and with that I do something similar and it has been working well for me.

Previously I was using CameraController.character and setting it equal to the player I instatiated
 
C#:
        m_character = BoltNetwork.Instantiate(BoltPrefabs.Nolan, spawnPosition, Quaternion.identity);
        var cameraController = camera.GetComponent<CameraController>();
        cameraController.Character = m_character;

This provides the same error. I just dont understand why having only one player in the scene works. I have the camera as a client side object and the characters as network side object. Doing it this way works when not using UFPS
 
Last edited:
My next guess is that this error isn't occurring for the first player, it's occurring for the second because there is no camera attached. For remote players you should create a new look source that uses the direction sent across the network for that remote player. This way the remote player has a look source that isn't the camera.
 
How would you recommend I do that? When the second player joins, it still gives them a camera just unattaches it. Both players see different things
 
The problem relates to the remote player joining when it should not have a camera attached. It still needs a look source - that look source will come from the direction that the camera is looking on the other client. This is extremely specific to the network implementation that you are using, but you'll need to create a new class that is activated only for remote players and gets/sends the look direction from one client to the server. You can take a look at the LocalLookSource component for an example of a stripped down look source used for AI.
 
Top