Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. JilJill

    JilJill

    Joined:
    Nov 11, 2009
    Posts:
    132
    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

    bgman

    Joined:
    Feb 17, 2010
    Posts:
    4
    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):
    1.  
    2. if (Input.GetButtonDown ("ReleaseMouse")) {
    3.   GetComponent(MouseLook).enabled = false;
    4. }
    5.  
    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 :)