Search Unity

Character Controller Auto Re-enables itself.

Discussion in 'Scripting' started by nonlin, Jan 30, 2015.

  1. nonlin

    nonlin

    Joined:
    Dec 12, 2013
    Posts:
    46
    I have set all scripts to be disabled by default and to turn on the moment a player is spawned. However, the moment I click play to run the game, Character Controller just enables itself after I have told it to be disabled.

    I'm practicing making a multiplier FPS game and I've managed to have cameras, sound listeners and FPSController default to disabled on launch and then set them to enable after they've joined the network. All except for Character Controller which I believe to be the culprit for an error I'm getting (NullReferenceException) on the line

    1. if(!_characterController.isGrounded)return;
    Which I think is due too double Character controllers existing in one scene at launch. (Since we have multiple players).

    The first person Controller script is the one that you get from the 4.6 Beta Sample Assets and it has a [RequireComponent(typeof (CharacterController))] at the top which I've committed out thinking to be the culprit to the ren-enabling but it still does so even without said line of code.

    So to sum up. I get an error regarding character controller the moment a second player joins. I realize that I've set all components except for Character Controller to disable on default (only to be re-enabled manually under photonView.isMine). Find out that Character Controller won't stay disabled. Post here hoping for help.