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 VIPINSIRWANI · Aug 30, 2013 at 09:09 AM · objectsreuse

How Can i delete Object Clone

Hi Everyone, I am making one ball game and i am trying to create obstacle's in a dynamic way, I am using Instantiate for creating obstacles but when i am trying to Destroy my old object (clone) on that time i am facing some problems. If anyone know the solution please give reply....Thank You

Comment
Add comment · Show 4
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 mattssonon · Aug 30, 2013 at 09:20 AM 0
Share

How do you expect people to help you if you don't explain what the problem is?

avatar image Hoeloe · Aug 30, 2013 at 09:22 AM 0
Share

mattssonon does have a point. In general, the more detail you can give on a problem, the better. Saying "I'm having problems" is not actually very helpful.

avatar image mattsson · Aug 30, 2013 at 09:45 AM 0
Share

We really shouldn't post answers for questions like this, we're only encouraging bad questions.

avatar image meat5000 ♦ · Aug 30, 2013 at 09:59 AM 0
Share

$$anonymous$$ake the call Destroy(gameObject) on the actual object. Can't go wrong.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Hoeloe · Aug 30, 2013 at 09:21 AM

If you are destroying the object from within it's own script, be sure to call Destroy on the GameObject (`GameObject.Destroy(this.gameObject);`, otherwise you're only destroying specific components. If you're trying to destroy it from outside it's own script, then you need to keep a reference to it when you instantiate it, which you can then call Destroy on (for example, use: o = Instantiate(...); followed by Destroy(o), where o is a GameObject variable).

Comment
Add comment · Show 6 · 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 united4life · Aug 30, 2013 at 09:59 AM 1
Share

Destroy(GameObject.Find("_(Clone)"));

avatar image VIPINSIRWANI · Aug 30, 2013 at 10:04 AM 0
Share

I am Using this Code but the problem is $$anonymous$$y prefab will also destroy after Destroy() I want to create Obstacles again and again in forward direction

IEnumerator Start() { yield return new WaitForSeconds(1.2f); create_instan(); }

 void create_instan()
     {
         
         for(float y = Y; y < Y + 5 ; y++)


         {
             for(float x = 0 ; x < 3 ; x++)
             { 
                 
                 GameObject bricks =(GameObject) Instantiate(brick,new V    ector3(x,y,0),brick.transform.rotation);
                  x = x + 1;
 //                bricks.GetComponent<BallTouch>().brick = GetComponent<BallTouch>().bricks;
                 Destroy(bricks,0.5f);
             }
             
         } 
     }
avatar image Hoeloe · Aug 30, 2013 at 10:06 AM 0
Share

...That won't destroy your prefab. Your prefab is called "brick", and you're destroying "bricks". What you are destroying is the specific instance of the prefab that you've just created, which you've called "bricks", not the prefab itself.

What that code will do is create an object and immediately destroy it, so at best you'll see the objects "flash" into existence, and then disappear.

avatar image united4life · Aug 30, 2013 at 10:09 AM 0
Share

prefab cannot be destroyed... may be you are trying to say is all the instantiated gameobjects are destroyed...

avatar image Hoeloe · Aug 30, 2013 at 10:11 AM 0
Share

Also, I don't know what you think you're doing, but you're not using a for loop correctly. First of all, you should use "int", not "float" for your for loops, and secondly, you're already incrementing x in the loop (that's what the "x++" does), but you're also doing it again later ("x = x + 1"), which means that x will increment by 2 each time. If you wanted that to happen, use "x+=2" in the loop, don't use 2 separate clauses.

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

21 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

Related Questions

clicking the right mouse button and add an object 1 Answer

Positioning Objects Next to Each Other in Code 0 Answers

(New UI) 3D objects as buttons? 1 Answer

Destroy Object On Touch? 2D 1 Answer

Orbiting objects appear stretched 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