- Home /
spell prefab recycling
Im pretty new to Unity and so far iv been crafting up my spell system. From previous ventures into unity iv learned that good scripts reuse projectiles from spells or guns or whatever. So i'd need 4-5 disabled prefabs floating under my character waiting for their turn in the 'clip' to be fired. But if i have a couple dozen spell effects thats going to be alot of disabled prefabs floating under my player in the 'clip' waiting to be shot. is this a bad way to go about that? also i was thinking maybe i make one super projectile that has all the effects of every spell attached to it, and it just activates the correct effects for the correct spell, and i'd only need 4-5 of those instead. are any of these good ideas, or does anyone else know a better way?
There is too little information here for a specific answer. Either solution will probably work just fine. Or you could go with a inbetween system where spells are not Instantiate()ed until the first time they are used. When I have questions like this one I usually test things out. Typically I'll come up with a "beyond-all-reason" scenario and see what happens. So populate your spell system with 200 spells and see if it creates any issues.
oh, its always the simple things i forget to try... thanks for the idea, i just did a stress test and it didnt start to lag until around 300 spells(which i would never get even close to) i think I'v found a good system. im just going to load 6-10 objects(based on spell refire speed) of a specific spell the first time a player equips the spell. then they will just hover around the world waiting to be refired.