I assumed that prefabs were a good way to design an entity in your game (i.e. set the model, materials, AI scripts, etc). Then you could reference that template in other scripts to create instances of the entity. However, based on further reading, it seems the only way to create prefab instances is via calls to Instantiate.
From the documentation, Instantiate only clones existing instances. When creating a new enemy, I would not want the state of a dead one. I want the original state defined in the template. Also, I would want any init (Awake() or Start()) scripting associated with the template to run when the new instance is created. Am I missing the point of prefabs and Instantiate?
What are best practices for defining an enemy template and using that template to stamp out instances via scription?
Hmm, it really isn’t too complicated.
In the Editor, your create your prefabs and spawns as many instances as you want just by dragging them in the scene, each of these instances will be untied when you hit Play and carry on with their own variables and stuff, leaving the prefab unnaffected.
Through code, whatever GameObject reference you pass as an argument will be used as the template for the cloned object, so you’ll want to pass the original prefab instance and not an already existing object, which probably has been modified (ie: you could spawn an already dying character).
Just add a GameObject reference somewhere and drag your prefab in and use that with Instantiate, done.
From the documentation, Instantiate only clones existing instances.
No, it’s used for instantiating prefabs from the project as well. That page you linked to describes the process in some detail. (Asset → Create Prefab, drag into project view, etc. Although a nifty shortcut is to simply drag an object from the scene into the project view, then it automatically creates a prefab from that object.)