EDIT: Someone knows what’s wrong with this, but I don’t understand what they’re trying to tell me! Can you guys explain to to me?
Hey, folks!
So, I’m having a heck of a time trying to figure out why my code isn’t compiling. It’s telling me that the Object Reference is not set to an instance of an object…but i’ve assigned all the variables in the inspector, and I know that the syntax for the variables in the scripts I’m referencing are correct. The syntax for the script I’m referencing is also correct. But it still tells me that the placer script is null when I put in a print statement.
It points to the first if statement, where I’m first referring to “placer”, when the error pops up. It might not mean anything, but the object that this script is placed on is parented to another object which is parented to the first person controller, which is where the placer script is…that wouldn’t change anything, would it?
Please, any help on understanding this would be really appreciated!
Spooked,
Simon
UPDATE: I’ve discovered that half the time it’s telling me that it knows what placer.number_of_objects is, and half the time it doesn’t…
var eyeofbeholder : GameObject;
var placer;
placer = eyeofbeholder.GetComponent("Music Placer");
var thislevel: int;
var switched = false;
function Awake()
{
audio.volume = 0.0;
}
function Update()
{
if((!switched && placer.number_of_objects==thislevel && (placer.music_level != placer.number_of_objects || placer.number_of_objects == 0)) || placer.music_level == thislevel)
{
switched = true;
placer.music_level = placer.number_of_objects;
Switch();
}
}
function Switch()
{
if(audio.volume == 1.0)
{
audio.volume = 0.0;
}
else
{
audio.volume = 1.0;
}
}
function Reset()
{
switched = false;
}