#Problem with Destoy(gameObject)

1 messages · Page 1 of 1 (latest)

tight sphinx
#

hi guyss I need help with a problem, Im trying to make a flappy bird game but whenever a destroy the pipe objects when they go of screen, I get an error telling me that "the game object has been destroyed but you are still trying to acces it." Help please

gusty folio
#

Just means something in your scene is still trying to reference it. In the error it should list out in blue what is causing the error. Mind posting the error message in full?

#

Also if you have a lot of things that need to spawn and despawn in the scene it's good practice to use a pooling system. Essentially just disabling and reenabling objects instead of deleting and instantiating them.

#

Here is a pooler I made that I use in just about every project. Slap it on a single gameobject in your scene. Then in code call Pooler.SpawnObject(obj, location) from anywhere

tight sphinx
#

im honestly pretty new to unity so im triying to learn all the basics before going into more complicated stuff

edgy cargo
# tight sphinx

If you click on your "Console" next to the "Project" tab, you can see the errors in more detail, double-clicking those errors should open Visual Studio (or whatever your IDE is) and jump to the line producing the error - the error itself should tell you more information about the script and line of code causing the issue