Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Dec 21, 2018 at 08:56 AM by Alpha-16 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Alpha-16 · Dec 16, 2018 at 11:22 PM · destroydestroy objectdestroygameobject

Unity createNew Game Object after calling a Destroy()

Hello all,

I'm having a weird issue with unity. When destroying GameObjects Unity creates a "New Game Object" GameObject into the outliner when the game is still running.

Here is my destroy call :

 private void DestroyBlock()
     {
        if (this.gameObject.transform.parent.gameObject)
         {
             gameController.RemoveBlockInMap(id);
             Destroy(this.gameObject.transform.parent.gameObject);
         }
     }
 
     void FixedUpdate () {
         if (blockCountAround != 8) {
           Invoke("DestroyBlock", lifeDuration);
         }
         else
         {
             CancelInvoke("DestroyBlock");
         }
         transform.Rotate(0.0f, Time.deltaTime * rotationSpeed, 0.0f);
     }


Here is the problem ingame : alt text

Each time I destroy a GameObject "PRE_BlockCoin" Unity creates me a "New Game Object".

Thanks,

48357919-2099650676759319-5813960897743290368-n.png (16.1 kB)
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 3kWikiGames · Dec 21, 2018 at 06:59 AM 0
Share

Could it be caused by the "CancelInvoke" ? I would leave some debug code in there to see if its canceling the destroy method.

avatar image Alpha-16 3kWikiGames · Dec 21, 2018 at 08:10 AM 0
Share

I does. As the blockCountArount value is always different during the course of the game.

1 Reply

  • Sort: 
avatar image
0

Answer by hexagonius · Dec 17, 2018 at 08:12 AM

does the console print anything? I suspect RemoveBlockInMap is creating it.

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 Alpha-16 · Dec 21, 2018 at 12:28 AM 0
Share

Nothing, I will try to look more into RemoveBlockIn$$anonymous$$ap

avatar image Alpha-16 Alpha-16 · Dec 21, 2018 at 08:55 AM 0
Share

It was indeed the source of the issue. I was creating a new GameObject inside the function to hold the value and delete the gameobject in the list at the end.

Follow this Question

Answers Answers and Comments

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

Related Questions

Script doesn't work anymore! 2 Answers

How do I Destroy a Child after Instantiating it? 1 Answer

Destroy Objects after a set time 2 Answers

transferring variables between scripts c# 3 Answers

Destroying Assests Not Permitted 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