Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-2
Question by hotozi · Oct 08, 2012 at 02:16 AM · instantiatenullreferenceexception

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;}
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DaveA · Oct 08, 2012 at 02:49 AM 0
Share

What is the exact text of the error, and please indicate which line number that corresponds to here.

avatar image Eli-Davis · Oct 08, 2012 at 03:21 AM 0
Share

Please format your code so our eyes don't burn out of our skulls.

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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!!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Object Reference Not Set To An Instance Of An Object! 0 Answers

unknown identifer explosion problem 2 Answers

Scripting error comes up when I press play 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges