many scriptableobject asset files

hi
i have a spell system that build a spell out of many small pieces
ex : fire ball = effect + projectile + damage
so for every spell i create i usually build it with 3 to 6 other SAB assets
since i’m trying to create a RPG like game i’m gonna end up with hundreds of spells for player and enemy’s
isn’t that gonna effect performance? having possibly hundreds of asset files?

Wouldn’t affect performance, but it would affect the overall install size of your game.
More assets = larger install size.

Of course, if these assets are fairly small in size individually, having lots of them shouldn’t increase the overall size of your game too much.

2 Likes

No. A ScriptableObject is essentially just a normal class that provides an easy way to serialize data to an asset and then modify it from an Inspector. The only way it would affect performance is if you needed to constantly call functions on or belonging to them. Otherwise they just consume memory (if loaded) and storage space. Feel free to go crazy with them.

thank you for your reply
they just contain data on how to behave, and one function that’s being called only when that skill is casted

I would pull those functions out somewhere else into a monobehaviour component with no Update loop and then load the struct data from the ScriptableObject when the spell was triggered if you are worried about performance.

i’m not really a good programmer, and this is the only way i came up with that helps me make a flexible spell system
since i created this so player and any other intractable can use it, i don’t know how to track them all and feed data into them
because once a spell is fired it keeps going even if the caster is destroyed because the existence of the action sequence no longer depends on the caster

Use the SO to store the parameters of your spell. Points scored or removed, translation, rotations and scaling values/ranges, colors, shaders…basically all the fields that your spell functions would make use of. Then write a component that has the actual functions that manipulate that data over time to execute your spell. Categorize your functions and write them so they extract the data from the SO for as many spells as you can stuff into that category.

For example TransformSpell may deal with the 25 spells that cause changes to the transform, 15 DespawnSpell may be called so when conditions from the SO are met it sets inactive or uses Destroy(some.gameObject). Create the minimal number of these SpellFunctions as possible to handle the range of interaction or causation. When triggered it calls the proper function for the spell type which loads the data from a particular SO to execute the effect you want to achieve.

You can have all these functions under one central component or a number of individual components. Create a List [for constantly resizing] or an Array[for fixed size] in the component and drag and drop all your SO scripts of the spell type. Grab the proper SO for the particular spell execution you want , perhaps a name in one of the SO fields that you pass into the function, which iterates the List or Array of SO’s in a for loop till it finds the one with the matching name field, extracts the data and then executes the spell algorithm using that data.

You can stuff 10,000 spells into a system like this and change the SO’s till your heart is content and write the functions only once.

thank you
i’ll try to implement this with the actions sequence i have