Hello, i try to enable scripts when a object spawns, but i got 2 scripts with the same name on this object.
I tried this:
But this does not work.
How can i enable the first, and after that the second fire script?
To get both scripts you could use GetComponents()
, as for enabling the first one after the second one, you might need to add some sort of ID to the scripts to know which is which, unless the array returned by GetComponents is in the order you need.
Note the plaurel GetComponents and the use of .
BUT this is horribly, terribly inefficient. Yo usould get the array once and then access it.
Fire fireComponents = ship.GetComponents<Fire>();
NOTE: If you start the game with a component not enabled, it doesn’t get created as disabled, it simply doesn’t get created at all.