![]() |
VOOZH | about |
ScriptableObjects are a special type of data container used to store and manage game data independently of scene objects. They help in organizing data efficiently and reducing memory usage by allowing multiple objects to share the same data.
Step 1: Create this script.
Step 2: Right-click Project - Create - Game - Enemy.
Step 3: Fill values in Inspector (Name: Goblin, Health: 50, Damage: 10).
Output:
Attach the ScriptableObject to your enemy script as a public field. Then drag the asset from Project into that field in Inspector.
You can create 50 enemies in your scene. All 50 will reference the same Goblin ScriptableObject. If you change Goblin health from 50 to 60 in the asset, all 50 enemies automatically have 60 health.
Create a ScriptableObject for weapons. Each weapon type becomes its own asset.
Create three assets from this class:
Now attach the weapon script to any character and drag any weapon asset into the data field. The character will use that weapon's stats automatically.