What I have so far:

A fuel that has Fuel script attached to it. The fuel prefab is first instantiated from another script in its Start() method.

problem: The Fuel script is such that it results in instantiation of prefab fuel repeatedly at some intervals of time and keeps destroying the earlier ones. But

the prefab that was instantiated from the other script stays there always. I want this prefab to be destroyed as well(or atleast made invisible) while the process of instantiation and destruction of of fuel prefabs continues to go on.

How do I achieve this?


Don't instantiate from the Fuel script. I mean, obviously if you don't want a second copy of the object then don't make a second copy of the object.

You say "the fuel prefab is first instantiated from another script"; so handle all the instantiating and destroying in that script, not just the first time.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.