Yeah ... but that'd change the prefab for all combatants of that type - and also only affect newly spawning prefabs, not the alrady spawned one.
Alternatively, you can just spawn a prefab and set it as the combatant's game object: combatant.GameObject = gameObject;
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I just noticed something odd. When spawning myPrefab and setting it as the combatant object, I end up with 2 combatants in the game instead of one: (1) the first derived from the Combatants>Base Settings>Prefab Settings which is using the Prefab set in the Makinom Editor. (2) the second from the myPrefab I spawned through code.
This is the code I used for spawning the combatant: CombatantSetting _settings = ORK.Combatants.Get("combatantGUID"); Combatant _combatant = ORK.Access.Combatant.CreateInstance(_settings, null, false, false);
You don't need to spawn the combatant before setting it's game object. Also, generally for such a case, that's due to Unity magic :) Spawning the prefab instance doesn't happen until the end of the frame, i.e. replacing the (not yet spawned) instance immediately after spawn doesn't destroy it.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Alternatively, you can just spawn a prefab and set it as the combatant's game object:
combatant.GameObject = gameObject;
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
When spawning myPrefab and setting it as the combatant object, I end up with 2 combatants in the game instead of one:
(1) the first derived from the Combatants>Base Settings>Prefab Settings which is using the Prefab set in the Makinom Editor.
(2) the second from the myPrefab I spawned through code.
This is the code I used for spawning the combatant:
CombatantSetting _settings = ORK.Combatants.Get("combatantGUID");
Combatant _combatant = ORK.Access.Combatant.CreateInstance(_settings, null, false, false);
_combatant.Object.Spawn(position, true, rotation, false, Vector3.one);
if(myPrefab!=null)
{
_combatant.GameObject = Instantiate(myPrefab , position, rotation);
}
I am not sure how to prevent (1) from spawning since the Prefab set in the Makinom Editor is just a placeholder and I don't need it.
Spawning the prefab instance doesn't happen until the end of the frame, i.e. replacing the (not yet spawned) instance immediately after spawn doesn't destroy it.
Try this:
if(myPrefab!=null)
{
_combatant.GameObject = Instantiate(myPrefab , position, rotation);
}
else
{
_combatant.Object.Spawn(position, true, rotation, false, Vector3.one);
}
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!