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
-1
Question by knuckles209cp · Oct 09, 2013 at 08:27 AM · objectnone

Object refernce not set to an instance of an object ....

before i ask this question , I HAVE looked at answers but none of them quiet fit the same sort of problem as mine .... Any way I have a little bit of my code here , im calling my RayShoot function to my other script called camshake ( for camera shake when i shoot ) but i cant figure out whats wrong. ( BTW its little bits of my code , all the braces are correct )

 var other : camshake;
 
    other = gameObject.GetComponent("camshake");
 
 
 function Start () {
    
 
    BulletsLeft = BulletsPerClip;
 
    muzzleFlash.emit = false;
    
    PHitParticle.emit = false;
 
 
 }
 
 
 
 
 function Update (){
 
   other.RayShoot ();
 
   if( KeyTimer > 0){
   
   KeyTimer -= Time.deltaTime;
   
   }


function Update (){

other.RayShoot ();

if( KeyTimer > 0){

KeyTimer -= Time.deltaTime;

}

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Azrapse · Oct 09, 2013 at 08:48 AM

Well. That error means that you are trying to access a member of a null reference. It should give you the specific line number where it happens, and you should give it to us, but I will guess...

It could be other.RayShoot() if other is null. And that could be null because other = gameObject.GetComponent("camshake"); cannot find a component of type camshake.

Are you sure the type name is spelled exactly like that?

Using the debugger is usually the answer to all your NullReferenceExceptions. Place a breakpoint on the erroneous line and examine the value of all involved variables within the debugger.

Comment
Add comment · Show 3 · 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 knuckles209cp · Oct 10, 2013 at 05:47 AM 0
Share

other = gameObject.GetComponent("camshake");

avatar image knuckles209cp · Oct 10, 2013 at 05:48 AM 0
Share

function Update (){

other.RayShoot();

avatar image Azrapse · Oct 10, 2013 at 06:33 AM 0
Share

Open the Cam Shake script and check the name of the class there. You must use that spelling.

Other than you mistyping the name of the component type, it could be that you are trying to get the Cam Shake component from the wrong game object. Without knowing your script structure any deeper I cannot help you more.

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

16 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 avatar image avatar image avatar image avatar image

Related Questions

How to Touch Drag 3D Objects 2 Answers

Manipulating Instanced Object 2 Answers

destroy object after a delay? 6 Answers

CCG: Creating a card object 2 Answers

Customizing/Morphing Player instantiated object 2 Answers


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