Hi,

I had a few questions regarding the Save System and how it works with Combatants.


1)I'd like to enable the ability to create a character with different race. After some forum digging it seems my best option for race might be conditional prefabs with a global race variable? This would enable me to have multiple race prefabs with different skeletal animations. Does this seem like a good use case for conditional prefabs?

2) I'd like to be able to modify the appearance of the conditional prefab at runtime. Both in the character creation screen and during game play. From what I understand, the Save System can handle some combatant save state but probably not what sprites are currently on a character? Does this mean I have to create custom save data or save this info on game variables?

3) How would I go about saving a list or dictionary in ORK? I'm thinking if ORK doesn't save the information about the instance of the prefab, a list of body parts and current sprites would be used to generate this information on load through a custom script.

4) What information does get saved about combatants?

5) does the combatant need to be spawned in a specific way for saving/loading to work properly (IE. using spawn combatant vs having combatant prefabs placed in the scene beforehand)?


Thanks!

  • edited August 2020
    1) Well, a global variable would only work if your player is the only one that has this combatant. Otherwise you can use object variables on the combatant to have a per combatant check.
    Or, you can use defence attributes for that as well.

    But yeah, generally you'd want to use conditional prefabs for that if you just want to change the appearance. Alternatively, you can also set up separate combatants and join the combatant you want to the player group based on the player's choice.

    2) You could use equipment for that, e.g. using hidden equipment parts that define the look of the combatant.
    Other than that, if you use a custom system, you can save the state of it via custom component save data.

    3) See the custom component save data for this. You can't save assets (like sprites) in a save game, though. You'd have to be able to retrieve that information some other way, e.g. having an array of sprites on your component and just saving the index of the one that's used.

    4) Everything status related (status values, abilities, equipment, status effects, etc.), inventory, group ... everything important. It doesn't save battle related states (e.g. turn).

    5) Loading a game will spawn your combatant at the position it had, unless you disable that in the save game menu settings (in which case you can load at a defined scene).
    Post edited by gamingislove on
    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!
  • edited August 2020
    Thanks for the tips!
    5) Loading a game will spawn your combatant at the position it had, unless you disable that in the save game menu settings (in which case you can load at a defined scene)
    I'm not sure if I was clear on my question here. What I was trying to ask was if combatant data is saved / loaded regardless of how they are added to the scene. My question stems from using Quest Machine and finding a bug that prevented the quest givers from saving their quest giver data. The developer said it was due to how ORK changed the way it saved semi recently to only save combatant data? They offered a solution of making my quest giver a combatant. I had manually added the quest giver to the scene and not used a spawner but the quest givers prefab was a combatant prefab. I'm not sure if ORK knows it is a combatant that way and if saves stuff or not.
    Post edited by foxx on
  • edited August 2020
    Also, does your answer to #4 mean the prefab saved and the prefab in the Ork framework menu are two separate instances? So If I changed equipment / sprites with it, then it would save that info separately?

    If a combatant who is an NPC changed their equipment. How would I access this new prefab?
    Post edited by foxx on
  • 4) Eh ... you do know how prefabs work in Unity, right?
    The prefab you select for the combatant in ORK is used to create a completely new, separate instance when spawning a combatant. Each spawned combatant is a separate instance and have no real connection to the prefab, i.e. any changes to them in-game will have no effect on the prefab.
    Changing equipment on your NPC/combatant will only affect that combatant, e.g. using equipment viewers to visualize them.

    5) Oh, ok - well, yeah, it matters.
    Usually only the player group will be saved, for saving other combatants, you have to enable saving them with save games (Spawned Combatants setting in Menus > Save Game Menu) and use the Remember Combatant options in Combatant Spawners or Add Combatant components.

    Also, just manually placing a combatant's prefab in your scene doesn't make it a combatant, so you'll have to use an Add Combatant component to actually put a combatant on that game object :)
    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!
  • edited August 2020
    Is it possible to add a sprite to a prefab, create an ORK armor with that prefab, and access that prefab's sprite from the players inventory via GetPrefabSettings().prefab.itemPrefab or something similar?





    Post edited by foxx on
  • A prefab is a prefab, if you add a sprite to it, it'll be on the prefab :)

    You could also use equipment viewers to display them on your combatant.
    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!
  • edited September 2020
    Right but I'm having trouble finding where the sprite lives. I tried getting sprite off the ItemPrefab.prefab but it came back null.

    Nvm, I got it.

    GameObject prefab = e.GetPrefabSettings().prefab.itemPrefab.prefab;
    Sprite sprite = prefab.GetComponent [SpriteRenderer] ().sprite;

    For anyone in the future.
    Post edited by foxx on
  • And I think equipment viewers might mess up the 2d unity skeletal animation and weights?
  • Equipment viewers just spawn and mount the viewer prefab you define for the equipment that's displayed - i.e. as long as that doesn't contain anything that would mess it up, it won't mess it up :)
    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!
  • edited September 2020
    I don't see how I could implement Equipment viewers without it messing up animations. From what I understand Equipment Viewers spawn an extra piece of equipment at their designated object. However, with Unity's 2d skeletal animation (using a layered PSB character), the Sprite Skin has references to bone transforms which are lost once you turn that individual object into a prefab.

    Example:
    example

    Even if you make the equipment viewer a child of the object that has the spriteRenderer/spriteSkin and keep the bones intact but spawn the sprite as a child, the sprite doesn't animate correctly.

    I'm following the (new?) 2d rigging method in Unity.



    I implemented a race swap by using equipment parts, inventory, and having a script change to the correct outfit on Awake. But if ORK allows me to do this in a better way I'd love to know how.
    Post edited by foxx on
  • Well, in that case probably not - equipment viewers have the child linking settings to match parts of an equipment to parts of the combatant's game object (e.g. sleeves following the arms), but I guess that doesn't work well in the 2D rigging.
    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!
  • edited April 2022
    I'm heading down a similar path and need to take this in to consideration.

    @foxx what was your solution to this?

    @gamingislove is there an update to the equipment viewer to work with Unity's 2D rigging system?
    Also, will the equipment viewer work with the mecanim animator?

    Thanks!
    Post edited by nuxvomo on
  • Not directly - equipment viewers are there to spawn equipment on the combatant, so that's not really compatible with the 2D rigging system, where they already have to be part of it.

    Instead, use a Game Object Manager to enable/disable stuff based on conditions, e.g. what's equipped.

    Equipment viewers (and game object managers) work with both legacy and mecanim animations.
    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!
  • OK awesome, looks like I'll stick with mecanim for now.
    Thanks for the explanation.
    Hope you're feeling better too!
Sign In or Register to comment.