Now that we have have Scriptable Objects and have made a few assets with them, How do we use them? As stated previously, Scriptable Objects and their assets can’t be used directly in a scene, so what are they used for? They are smart data containers that can have some basic program logic which allows use to use them a bit like abstract classes, but a bit in reverse.
In this example, I have set up a custom class for the individual pokemon that the play may encounter or catch. We can store a reference to the pokemon base species asset and access it to determine the pokemon’s base abilities.
Here is the constructor method for the Pokemon Class that I am using. When we create the new pokemon, we also assign the Pokemon Base asset. We can then use the values in the asset to set the pokemon’s base stats. As one of the final steps, after all the stats are assigned, we give the pokemon it’s first level. This will allow the pokemon to use the base stats and the randomly generated modifiers, such as nature and IVs, to generate the actual stats of this individual pokemon.
As for what happens when a pokemon evolves into a new form/species, It is just a matter of replacing the asset reference and use it to update the base stats.
After all this, it comes down to working with the specifics of pokemon such as moves and the math involved in calculating stat changes.
And with this basic knowledge you should be able to build your own system that uses scriptable objects, be it for races, classes or jobs. You also will create items for an inventory system. Let’s see what you can come up with.