I am using this function to get a combatant's status value. Seems to be working ok with positive values but fails with negative ones.
Is it a problem to use negative status values or did I do something wrong in the code?
public static int GetCombatantStatusValue(GameObject item, string _guid)
{
if (ORKComponentHelper.GetCombatant(item) != null)
{
Combatant combatant = ORKComponentHelper.GetCombatant(item);
Debug.Log("GetCombatantStatusValue for " + item.name + "succeeded and gave " + combatant.Status[ORK.StatusValues.GUIDToIndex(_guid)].GetValue() );
return combatant.Status[ORK.StatusValues.GUIDToIndex(_guid)].GetValue();
}
Debug.Log("GetCombatantStatusValue for " + item.name + "failed ");
return 0;
}
  • What do you mean it fails - does it cause a bug or just return 0?
    Generally, status values can be negative, if they're set up to allow that by their min/max value settings. The default setup for status is in the positive value range, though.
    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 March 26
    Seems like it fails since it does not generate any debug log (not even Debug.Log("GetCombatantStatusValue for " + item.name + "failed ")
    Post edited by ChimpLogik on
  • Sounds more like this isn't called at all - where is the function called from?
    If the function failed in any way, it'd cause an error message in the Unity console.
    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!
  • Took me a while to figure it out but the issue was that the combatant was null at Start().
    I had to delay by one frame ORKComponentHelper.GetCombatant(this.gameObject) and now it works.
    Still trying to understand where that delay is coming from.
    Thank you for the help Nicholas :)
Sign In or Register to comment.