It seems Scriptable objects is a tool all unity devs love, so as someone who has no proper education, I feel like I’m doing something wrong when I find them a bit inconvenient or overkill at times.
I work component based, so lets say I have have a Unit, this unit has some health, can attack enemies, and can move. With an object like this I would add the following components:
Health
Attacker
Mobile
I just feel like it’s an extra step to store the data for these components in scriptable objects, for example:
Health: int maxHealth
Attacker: int damage, int attackSpeed
Mobile: float movementSpeed
Why should I create a Scriptable object (or 3) for the above scenario to store those variables, in my game you can have 30+ different units, thats a lot of SOs. I don’t find it easier to open up a scriptable object and edit it compared to simply opening up my prefab and editing the component itself in the inspector.
If you will not reuse then it makes less sense. For example take a firearm as example. There are maybe a number of pistols that fire 9mm projectile. Then you can just drag and drop the 9mm scriptable okject to each firearm that fires it. If you want to change 9mm projectile ballistics you change the scriptable object and it will change for all firearms using it
For objects that exist in the world, like your examples, it really doesn’t make much of a difference. For things that don’t need a physical presence, like abilities or equipment, they make a lot more sense.
If all I need to do is plant a small cup size flower… a tractor is overkill.
The fact I only need to plant a cup sized flower does not mean the tractor is overkill in general… it means it’s overkill for planting a cup sized flower. Use a normal hand trowel instead.
Use the right tool for the right job.
…
As @GroZZleR pointed out, ScriptableObject’s are great for things that don’t need a “physical” presence (in this case ‘physical’ is in reference to existing in a scene).
I personally like to draw from things Unity has made that mirror ScriptableObject. Before ScriptableObject existed there was no easy way to create my own versions of things like ‘PhysicalMaterial’ or ‘AnimationController’ or really ANY custom asset type. I could only create the built in one’s, or prefabs with components attached being the only custom code injection point I had for assets.
ScriptableObject covers this.
There was a thread recently where someone suggested that ScriptableObject is a terrible name for what it is as it does not convey what it’s actually trying to do. If I recall the suggested alternative name was “ScriptableAsset” or something to that effect.
Because that’s what it is… it’s a way for you to script your own assets.