So I have a white die object named whiteSixSidedDie currently in my scene. (eventually I want to move it out so I can instantiate it as needed).
This script is on it:
var whiteDie:GameObject;
function Awake()
{
whiteDie=GameObject.Find("whiteSixSidedDie");
Debug.Log("I've Found the white die");
whiteDie.GetComponent.DieValueWhite.enabled=false;
Debug.Log("I've disabled the value script");
}
function Update()
{
Debug.Log("I'm continuing to calculate the velocity of the die");
if(whiteDie.velocity.magnitude<=0)
{
Debug.Log("I've calculated the velocity. The die has stopped moving");
whiteDie.GetComponent.DieValueWhite.enabled=true;
Debug.Log("I've enabled the script to assign the value to the global variables");
}
}
Now I keep getting a null reference exception on the “whiteDie” variable. I’ve check and checked and the spelling is all correct for the different variables and names. The first debug log works, but right as I start the “GetComponent” command, I get the null reference exception stating that the object reference is not set to an instance of an object. But it is, whether I go through the inspector assignment or the script, I still get this error.
I’ve also tried replacing all the “whiteDie” text with a “this” since this script resides on the object I’m attempting to work with and I still get the same error.
So can anyone tell me what I need to change so this script works?
Thanks!
-Kaze-