Switching between Player Controls and Behavior Designer

hakul0

New member
Hi,
I am struggling to find a way of switching between player controlled character and behavior designer controlled. I need two characters active at one time and ability to switch between them.
Is there any simple method to do so?
If not, how to disable character's camera properly. Currently if I do it just by setting it inactive, it glitches the character's arms or throws exception in Combat.GetDeltaYawRotation method.
 
Last edited:
It also glitches if I activate a character from being inactive when there are multiple characters in scene.
 
Last edited:
You can disable/change the object that the camera follows by setting the Character property on the CameraController. If you set it to null then the CameraController will disable itself.
 
You can disable/change the object that the camera follows by setting the Character property on the CameraController. If you set it to null then the CameraController will disable itself.

I am trying to switch between characters like this:
Code:
characterComponent.gameObject.SetActive(true);
EventHandler.ExecuteEvent(characterComponent.gameObject, "OnEnableGameplayInput", _isPlayer);
camera.Character = _isPlayer ? characterComponent.gameObject : null;
camera.gameObject.SetActive(_isPlayer);

But it throws a null object exception:
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.FirstPersonController.Character.MovementTypes.Combat.GetDeltaYawRotation (Single characterHorizontalMovement, Single characterForwardMovement, Single cameraHorizontalMovement, Single cameraVerticalMovement) (at Assets/Opsive/UltimateCharacterController/FirstPersonController/Scripts/Character/MovementTypes/Combat.cs:28)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.GetDeltaYawRotation ()

It also disables FirstPersonCamera for the active character, but leaves the main one going.
 
Top