Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

disabling c# script from javascript file when instantiaiting new network player

Discussion in 'Editor & General Support' started by jimjim, Apr 4, 2011.

  1. jimjim


    Nov 11, 2009
    I am trying to disable a c# script when i instantiate a new player in a game. But i keep getting the same error when a new player instantiated:

    NullReferenceException: Object reference not set to an instance of an object
    S2L_PlayerScript+OnNetworkInstantiate$102+$.MoveNext () (at Assets\Standard Assets\Scripts\networking\m2hScripts\game\Scripts\S2L_PlayerScript.js:69).

    I have tried to comile my mouselook script before my player script but nothing seems to happen. Any ideas would be nice thanks
  2. bgman


    Feb 17, 2010
    I have a similar problem I'm trying to fix. In a (javascript) script attached to the same gameobject the MouseLook script is attached to, I have:
    Code (csharp):
    2. if (Input.GetButtonDown ("ReleaseMouse")) {
    3.   GetComponent(MouseLook).enabled = false;
    4. }
    And I get the error "NullReferenceException: Object reference not set to an instance of an object". Does this problem have something to do with a bit of Javascript trying to enable/disable a .cs script? Can't figure it out, which is irritating, because this seems like it should be trivial :)