ScriptableObject Referencing

Hey, I am asking for some clarification on scribtapleobjects. I have a scriptable object for the player stats like health and damage. I have a script for managing an enemy which takes damage if a projectile hits it, the problem is I need the players damage numbers to accurately decrease the enemy’s health. However this is locked behind the scriptableobject and I am unsure how to reference it in another object that get’s instantiated.

Should I keep the numbers on the player gameobject and just find that in the scene or is there some good way to get the data in the scriptableobject without causing null references? I do not want to use the Resources folder 'cause it gets slow.

Hi!

If the object that gets instantiated is a prefab, why not just drag in the player stats scriptable object into that prefab? That way it will get instantiated with the info.

Alternatively you can have a field for the scriptable object in whatever is instantiating this object, and then change it as it gets spawned in.

Hope this helps!