- Home /
Accessing a specific scripableobject index that can spawn from a single prefab
So for starters. I will have scriptable objects for playable characters and enemies. Which will store all the damage, health, sprite, level, speed, abilities(which will come from its own scriptable object as some will duplicate across different characters) etc etc. And within all of those SO, create the properties to reference later. This I understand and can accomplish.
Next. Create a single prefab for a playable character. And a single prefab for a enemy. With a script to reference the properties we created above. Pretty sure I have that figured out. The prefab mainly would consist of colliders/rigidbody for movement and interaction. Everything else coming from the SO.
Now where I get a bit confused. And I guess it's also done somewhere in the last step. Is assigning which scriptable object to reference when spawning a enemy or playable. I can manually drag a SO into that slot in the inspector and it'll do what I want. But for script based spawning, based on map or area. Not sure how to proceed. I assume make a list/dictionary for each playables and enemies. But where in the instantiate prefab process would I call for the index from the list to then spawn with the correct information.
But can't seem to create that connection. Assuming I'm going about this correctly. Any help would be appreciated!