I made some abilities and was wondering what would be a good way to add these abilities to the player gameobject whenever they’re found in the game, and activate/deactivate them depending on which abilities are equipped.
I’m pretty new to coding, some suggestions would be appreciated!
Would it be a bad idea to just leave all the deactivated abilities on the player at all time and activate them only once the player gains and equips the abilites?
Is it possible to save the public references somehow so that when adding new scripts they would already be referenced? Or would i have to reference them on Start?
I think the best way to do this would be to leave them disabled then enable them when the player gets the ability - basically what you said in your 2nd post.
Create a separate script that stores all the references to the ability scripts then use it enable / disable them accordingly.
I’m guessing you are only going to have a couple of abilities, passives, whatever, whatever. Having them in a list isn’t inefficient at all. Even if you had a hundred it wouldn’t be that bad. That’s still a small fraction of time for the computer to loop through. You have a good start on what to do. If you realize after implementing it’s insufficient or doesn’t work then you can change it but I would first get the basic bare bones out. That’s the best way to understand how you want it to work and see it work.
That’s good to know, i’m sure there’s a cleaner way to do this, i’m still a bit new to scripting but it would be nice to have all the ability scripts in one script, like in a list or something, make a list of all the acquired abilities and only activate the ones equipped, i’l try to figure something out but suggestions are always welcome.