Disable/enable UCC at runtime

buhu

New member
Hello.
I want to completely disable and later enable whole character and camera at runtime.
I manage to do it by simply putting camera and character under one parent and disabling it but I getting this ugly error


IndexOutOfRangeException: Index was outside the bounds of the array.
Opsive.UltimateCharacterController.Game.KinematicObjectManager.SetCharacterMovementInputInternal (System.Int32 characterIndex, System.Single horizontalMovement, System.Single forwardMovement) (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:630)
Opsive.UltimateCharacterController.Game.KinematicObjectManager.SetCharacterMovementInput (System.Int32 characterIndex, System.Single horizontalMovement, System.Single forwardMovement) (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:619)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:71)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.OnRespawn () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:285)
Opsive.Shared.Events.InvokableAction.Invoke () (at <fa7bae0bde914e57874fdb6999909243>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent (System.Object obj, System.String eventName) (at <fa7bae0bde914e57874fdb6999909243>:0)
Opsive.UltimateCharacterController.Traits.Respawner.Respawn (UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, System.Boolean transformChange) (at Assets/Opsive/UltimateCharacterController/Scripts/Traits/Respawner.cs:197)
Opsive.UltimateCharacterController.Traits.CharacterRespawner.Respawn (UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, System.Boolean transformChange) (at Assets/Opsive/UltimateCharacterController/Scripts/Traits/CharacterRespawner.cs:39)
Opsive.UltimateCharacterController.Traits.Respawner.Respawn () (at Assets/Opsive/UltimateCharacterController/Scripts/Traits/Respawner.cs:166)
Opsive.Shared.Game.ScheduledEvent.Invoke () (at <b04654ce13d840b1982d389f518c3c84>:0)
Opsive.Shared.Game.SchedulerBase.Invoke (Opsive.Shared.Game.ScheduledEventBase scheduledEvent, System.Int32 index) (at <b04654ce13d840b1982d389f518c3c84>:0)
Opsive.Shared.Game.SchedulerBase.Update () (at <b04654ce13d840b1982d389f518c3c84>:0)



How can I get rid of it... or maybe there is another - correct - way of disabling player?
 
I want to work on improving the workflow so you don't need to call SetActive on the locomotion component. I just tried to reproduce this but wasn't able to. If you create a new scene and perform the following do you get the error?

1. Setup a new character
2. Setup a new camera
3. Create an empty GameObject, move the character and camera underneath it.
4. Hit play. Disable that empty GameObject from the editor.
5. Enable that GameObject.

Performing these steps I did not get any errors.
 
Top