Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Xavier78 · Jul 10, 2015 at 06:47 AM · javascriptscript errorcallon

Object reference not set to an instance of an object

So I have this script that looks at the ground and says, "heay ground do you have Fricion?" and most of the time its all like, "You know I do dog." But some times it is like "Nope whats that."

In case of the latter the script is all like, warning warning. Object reference not set to an instance of an object. But I want it to be like "that's cool what evsss."

how do I make it not give out an error when looking for the attached script.

this is how I am calling the script.

transform.GetComponent(Colliding2).StandingOn.GetComponent(Properties);

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 zohaib817 · Jul 10, 2015 at 07:21 AM 0
Share

can't understand what are you saying. elaborate it kindly.

avatar image Hellium · Jul 10, 2015 at 07:32 AM 0
Share

$$anonymous$$ake some research before posting thanks

http://answers.unity3d.com/questions/47830/what-is-a-null-reference-exception-in-unity.html

1 Reply

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

Answer by ransomink · Jul 10, 2015 at 07:37 AM

Your speech is off-putting and very confusing. Proper English may help in this situation. Seems you need to check if the instance is null, possibly something like:

 if (TheGameObjectOrComponentYourTryingToAccess != null)
 {
     transform.GetComponent(Colliding2).StandingOn.GetComponent(Properties);
 }
 else
 {
     Debug.Log("There is no Instance for this GameObject or Component);
 }

Not sure if this will work because you have not given a snippet of code or the line of error; so I don't know what Object (GameObject or Component) is not referenced.

Comment
Add comment · Show 2 · 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 Xavier78 · Jul 10, 2015 at 07:43 AM 0
Share

basically that is all I needed, and it is late here, so that is why my question was making of the little senses. And in the future, the hole get component is what is being referenced, in this case it was a script on another object.

avatar image ransomink · Jul 10, 2015 at 09:14 AM 0
Share

I'll let it slide. It's past 4am here so I feel your pain, haha!

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

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

Related Questions

Changing a Variable in a script from another Object 1 Answer

An instance of type 'UnityEngine.BoxCollider2D' is... 1 Answer

Javascript return statement 1 Answer

call unity javascript from cs plugin 1 Answer

Changing mouse sensitivity 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