- Home /
NullReferenceException: I think unity bug
i looked every where...check back, make a new script but no way!!!
NullReferenceException: Object reference not set to an instance of an object :blablabla UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator) :blablabla
tell me where is the problem.... because now it just make no sens!!
...............
//things
var Target:Transform;
var BSpawn:Transform;
//parts
var VacumPod:Transform;
var Pod:Transform;
//Amos
var CrateAmo:int=0;
var CrateAmoMax: int=0;
var EnergyBoxAmo:int=0;
var EnergyBoxAmoMax:int=0;
var ReactorAmo:int=0;
var ReactorAmoMax:int=0;
var MineAmo:int=0;
var MineAmoMax:int=0;
//bullets
var Mine:Transform;
var Crate:Transform;
var EnergyBox:Transform;
var Reactor:Transform;
private var ShotPose=false;
...........................................................................................................................................................................................................................................................................
function Update ()
{
if(CrateAmo>CrateAmoMax){CrateAmo=CrateAmoMax;}
if(EnergyBoxAmo>EnergyBoxAmoMax){EnergyBoxAmo=EnergyBoxAmoMax;}
if(ReactorAmo>ReactorAmoMax){ReactorAmo=ReactorAmoMax;}
if(MineAmo>MineAmoMax){MineAmo=MineAmoMax;}
/////////////Distance and see the player
var Pdistance=Vector3.Distance(Target.position,VacumPod.position);
if(Pdistance0){
varCratez=Instantiate(Crate,BSpawn.transform.position,BSpawn.rotation);}
Cratez.transform.rigidbody.AddForce(transform.forward*100000);
yield WaitForSeconds(3);ShotPose=false;}
...........................................................................................................................................................................................................................................................................
function ShotReactor(){ReactorAmo-=1;
if(ReactorAmo>0){
var Reactorz=Instantiate(Reactor,BSpawn.transform.position,BSpawn.rotation);}
Reactorz.transform.rigidbody.AddForce(transform.forward*100000);
yield WaitForSeconds(3);ShotPose=false;}
...........................................................................................................................................................................................................................................................................
function ShotEnergy(){EnergyBoxAmo-=1;
if(EnergyBoxAmo>0){
var EnergyBoxz=Instantiate(EnergyBox,BSpawn.transform.position,BSpawn.rotation);}
EnergyBoxz.transform.rigidbody.AddForce(transform.forward*100000);
yield WaitForSeconds(3);ShotPose=false;}
...........................................................................................................................................................................................................................................................................
function ShotMine(){
MineAmo-=1;
if(MineAmo>0){
varMinez=Instantiate(Mine,BSpawn.transform.position,BSpawn.rotation);}
Minez.transform.rigidbody.AddForce(transform.forward*10000);
yield WaitForSeconds(3); ShotPose=false;}
What is the exact text of the error, and please indicate which line number that corresponds to here.
Please format your code so our eyes don't burn out of our skulls.
Answer by hotozi · Oct 08, 2012 at 04:03 PM
Soory for that....but unity said 8 of my lines ahave null object....so i put every variables and influenced lines...i didnt found it...but i changed it!! so now its good!!
Answer by Owen-Reynolds · Oct 08, 2012 at 02:34 AM
In Unity, you can double-click on the error to jump to the exact line causing it.
A "Null Reference" is a common error, for everything, not just Unity. There are lots of places to read about what it means. In general, it means you're talking about some "Object" which doesn't exist -- so you're referring to something which is null. But, again, easy to search for common examples.
Answer by Eli-Davis · Oct 08, 2012 at 03:24 AM
When you fire your bullet, your prefab might not have a rigid body attached.