edited July 2022 in ORK Support
Is there a way to set a Combatants prefab in Combatants>Base Settings>Prefab Settings>Prefab so it's selected randomly from a list/array of prefabs?
I tried using Conditional Prefabs but I didn't find a solution.

Also, is there a way to swap the prefab when the combatant changes level?
Post edited by ChimpLogik on
  • Conditional should work. For instance setting it to a variable condition that is randomly set by a schematic would randomize which prefab spawns.
    Miuratale : coming 2024
    Miuratale
  • Hmm, so I would have to create a bunch of different schematics with different ranges in order to generate valid indexes?
    For example if I have 3 conditional prefabs I should use the [0,2] schematic and so on...

    Regarding swapping a combatant's prefab runtime I'm thinking to use this:
    combatant.GameObject = Instantiate(prefab, position, rotation);
    but I am not sure how to destroy the previous prefab without destroying also the combatant object itself.
  • You can use the combatant's object variables settings and conditional prefabs based on those variables without using schematics.
    E.g. check out how this 2D Grid Battle RPG tutorial randomize combatants.

    The combatant's spawned prefab is the combatant object, so just replacing the game object (as your code example does) is all you need. Though, when using conditional prefabs, that might be overruled sometime later when the conditions are checked (e.g. when something changed that is used as a condition).
    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!
Sign In or Register to comment.