- Home /
Unity is acting REALLY weird
Hi!
Today when I started up my project it worked as it did yesterday. But when I open up MonoDevelop and I just edit something, I get this error "Object reference not set to an instance of an object". I've never gotten that before in this situation! I just appears of no reason. It is pointing to his line:
if (Input.GetButtonDown ("Shoot") && aiming == true && fireTimer > fireRate && glockWepStats.currentAmmo > 0) {
It doesn't like the && glockWepStats.currentAmmo > 0 of some reason. It works yesterday and when I hadn't opened up MonoDevleop yet. When I remove it, it says there is no AudioSource on the glock weapon. "There is no 'AudioSource' attached to the "Weapon-Glock" game object, but a script is trying to access it.". When I look at the glock weapon, there is a AudioSource!
Why is this happening?! I restarted Unity and my computer but it is still the same!
But have you properly referenced the component via script?
You should ad the line where you are declaring your sound component and you can check if the glockWebThingy exist by putting a Debug.Log(glockWebThingy.gameObject.name); before the if statement.
Yes. I have referenced it. But now it seems to work. This is so weird...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Scripts were perfect but now they are all messed up please help 0 Answers
Enemy AI problems & Tree problems 0 Answers
A node in a childnode? 1 Answer
I can't shoot up or down. HELP! 1 Answer