- Home /
Disable/Enable Script or Add/Remove?
I have a player that, when he has a powerup, activates an effect script that I wrote. Should I have it so that each time the player gets the powerup, the script is added to the player, and then when he loses the powerup, the script is removed? Or should I have it so that the script is always attached to the player, and it enables/disables when the player gets and loses the powerup?
Answer by rutter · Aug 10, 2014 at 04:26 AM
As far as Unity's concerned, either or both are perfectly acceptable solutions.
Which one works better for your game? That depends on what you're trying to do, what your skills and preferences are, and how your systems are put together.
One game might value simplicity in design, and therefore might go for the add/remove approach. Maybe your components avoid depending on each other. Maybe that's the simplest way to make it work.
Another game might value performance, or might have components that reference each other regularly. That game might go for the enable/disable approach.
Point is, they're both valid. Do what works for you.