So it’s a simple question, I hope, before I make a mistake I wanted to ask someone who’s more knowledgeable about this stuff.
So I’m making a Turn-Based RPG to be my first commercial game, I can’t stress how much I’m on the nervous side coding it.
So as the title says it’s about Scriptable Objects, so of course I’ll have only one player in the game, so I created only one scriptable object with his stats and some functions to check if he’s dead and some other stuff. And seeing that there’s only one player, I don’t see much harm doing it like this.
Now for the enemies, I have one SO for the only test enemy I have in the game for now, of course I’ll add more enemies with different stats, so… Should I only use this one SO for all the enemies, or do I have to create multiple SOs for each enemy in my game?
Scriptable Objects should mainly be used for data. Think of it as an elaborate .txt file. You probably wouldn’t put any functionality for checking if the player is dead in there. They are for representing the player name, stats, weapon damage, enemy sprites, settings or whatever, as they don’t need to exist in the scene as a GameObject. So there actually is harm in putting that function in there. It should be in a script attached to the player instead.
For the enemies it just depends on what you’re trying to do. Again, you only save data in these. So if enemies have a name, damage values and stats, you put the variables for that in a SO and then start creating one for each enemy. Again, and I can’t stress this enough - just data goes in there. To actually implement the functionality you still need a script on your enemy that references the SO. For example you have EnemyData.cs which derives from ScriptableObject and you have Enemy.cs which has a [SerializeField] EnemyData. And that’s where you pull all the information from like enemyData.hp and so on.
Oh yeah, I mistyped that, I didn’t mean I had functions on the SO, I have those functions in a empty Game Object in the scene, I’m stupid, but not by that much.
But anyways thank you for the reply, I just wanted to know if creating enemies like that was a good idea or not, and I already have in mind how to parse the data between scenes! Thank you and have a good day!