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 Djaydino · Feb 26, 2013 at 05:17 PM · destroyactivemissingreferenceexception

MissingReferenceException

i have i iceball hitting a paddle then that paddle is surrounded with ice, when i tap the ice it will break and i can move the paddle again.

now, when i start the game it works the 1st time, the 2nd time i get this error : MissingReferenceException: The object of type 'iceCube1' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.

and the ice cube stays visibble, the cube can't be broken and the paddle can't be moved.

i know it has to do with "Destroy" i tried gameObject.active=false; but somehow the paddle won't move after breaking the icecube.

i have uploaded the snippets here : Iceball :

http://codeviewer.org/view/code:300a

iceCube :

http://codeviewer.org/view/code:300b

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
Best Answer

Answer by GC1983 · Feb 26, 2013 at 05:47 PM

So, the only thing thats breaking and destroying is the IceCube, right? Well, obviously you have destroyed the object you want to reference. doing gameObject.active = false also will turn off any source of recognition that the object is still there. So any scripts that is searching for it, wont find it. Trying gameObject.renderer.enabled = true/false. That just turns off the mesh and keeps the object active.

Comment
Add comment · Show 13 · 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 Djaydino · Feb 26, 2013 at 09:52 PM 0
Share

this works thx. how can i best change the instantiate line (43&53) in the Iceball script? i made already an if GameObject exists for it

i'm still kinda new @ this :)

avatar image Djaydino · Feb 26, 2013 at 09:56 PM 0
Share

i mean to enable the game object again

avatar image GC1983 · Feb 26, 2013 at 09:56 PM 0
Share

Youre going to place the icecube object into the scene before game play. Place it exactly where you would instantiate it. $$anonymous$$ake sure the renderer is turned off so it cant be seen. And then call gameObject.renderer.enabled = true where you would call the instantiate.

avatar image Djaydino · Feb 26, 2013 at 10:06 PM 0
Share

hmm.. can't do that because the paddle is moving and should be trapped in the icecube on the position it got hit by the iceball

avatar image GC1983 · Feb 26, 2013 at 10:30 PM 0
Share

Sure, just attach the hidden object to the paddle. The icecube will be the child object of the paddle. Then relocate it where you want. So it will move with the paddle and when you enabled the renderer when the snowball hits the paddle, it will appear right where you would have instantiated on the paddle.

Show more comments

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

10 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

Related Questions

How To Keep GameObjects From Enabling Again? 2 Answers

Destroy and instantiate far objects 2 Answers

Button to create object??? 1 Answer

Active Prefabs 1 Answer

using Contains(gameObject) to find and destroy a gameObject from a list 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