0
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

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.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .