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
0
Question by kag359six · Aug 29, 2012 at 11:08 PM · transformobjectinstance

object not set to instance..........again.

So i have had this issue before, and it has been dealt with in a different scenario, however i can't come to a solution for this one. when i call a function in another script it tells me that it needs to be set to an instance of an object, and im assuming its refering the the "this.transform" part. What's a work around for this?

  else if(!terrain.chunksToRender.Contains(this.transform)) { 
             
             terrain terrainScript = player.GetComponent<terrain>(); 
             terrainScript.renderChunk(this.transform); //here lies the issue
             terrain.chunksToRender.Add(this.transform);
             
         }
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

2 Replies

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

Answer by Cripple · Sep 04, 2012 at 09:50 PM

Hi,

It must be terrainscript which has a null reference. Are you sure that you have attached the script terrain to your GameObject player ?

If you want to debug, just try something like this :

 terrain terrainScript = player.GetComponent<terrain>(); 
 if( terrainScript == null)
 {
          Debug.Log("terrain script not found");
 }
 else 
 { 
          terrainScript.renderChunk(this.transform);
          terrain.chunksToRender.Add(this.transform);
 }

You should also give your script/class name a name starting with a upper case, it is a C# convention. Here you should have "Terrain" instead of terrain.

Comment
Add comment · Show 1 · 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 kag359six · Sep 04, 2012 at 10:49 PM 0
Share

SWEET. It turns out that player didnt have that script, it was some other object and i totally forgot that i assigned it to a different object lol thanks.

avatar image
0

Answer by Screenhog · Aug 29, 2012 at 11:18 PM

Can't you just do "transform" instead of "this.transform"? I don't know if the word "this" is actually used anywhere in Unity.

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 kag359six · Sep 04, 2012 at 09:26 PM 0
Share

That still gives me the same "object reference not set to instance" error.

avatar image AlucardJay · Sep 04, 2012 at 09:31 PM 0
Share

this. is accepted by Unity, just as the keyword new (new Vector3) is accepted in uJS. They are not required, but they work =]

Sorry, I cannot help with your problem in C# though, it is merciless if you don't declare things as it likes :(

unless it's something simple like the method renderChunk is not set as public void?

avatar image kag359six · Sep 04, 2012 at 10:49 PM 0
Share

Cripple's answer was correct

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

9 People are following this question.

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

Related Questions

Acces to other object trigger thru other object script 0 Answers

how to scale the transport? 1 Answer

I need help with the location of instatiated objects on the scene and correct interaction with this 2 Answers

How to move an object to your current positon? 0 Answers

How do I restrict game to only instantiate 1 instance of object? 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