I've come across an odd behavior where attempting to add 1 to the float of an ability variable inside a formula gives two extra points. If I check against an original value of 1, it shows the value to be 3, and if the original value is 1 then 4 is correct. I'm selecting only one ability, and it has only 1 level with just the one variable, so the issue shouldn't be stemming from there. I've also simplified the formula to basic steps:

Step 1 - Select ability

Step 2 - Change the value

-type: selected

-selected key: set as value and left blank (I didn't assign a name to the value field of the selected variable, so it just checks against whichever variable is currently selected)

-value type: value

-value: (the variable's name)

-type: float

-operator: add

-float value, value type: value

-value: add

-Step 3: check game variable. I set up the basics as above and check whether the float equals a specific number

-Step 4: the check node empties into a pair of value nodes. 1 for pass, 0 for fail. If the proceeding check node is set to 1 after adding one via the change variable node, then the ultimate value is 0. If I set it to check whether the value is 3, then the formula value becomes 1. aka true. Any thoughts on where those extra two points might be coming from?
  • Step 4 is a bit hard to understand - are you using Value nodes to change the formula value or again changing the ability variable? Also, is the proceeding check node checking the formula value or ability variable you changed?
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • The node checks the variable's value, and the variable value is being changed. I haven't been able to reproduce the bug since I closed and restarted Unity though, so maybe it was something temporary to do with Unity itself. I never did figure out where the other two points were coming from.
  • Damn it, there it is again! The problem definitely lies somewhere in the difference between 'Add' and 'Set'. If I set the variable and go directly to the check node, then the value is correct. Similarly, setting the value and then adding to it adjusts correctly, but if I simply jump straight to adding then it gives me the extra points. It's not the variable itself; I've tried creating new variables and used the same procedure. Regardless, adding one to an ability variable that's set by default to zero should be giving me a one when I tell it to add one, whether or not I tell the formula to set its value to zero beforehand. I've also made certain, on numerous attempts, to copy and paste the variable directly in the formula nodes to rule out that haven't been attempting to alter a non existent variable. That's not the issue either.
  • Add naturally adds to the already existing value of the variable - i.e. if you don't reset it somewhere (e.g. at the start or end of the calculation), you'll often work on already changed values.

    E.g. the hit chance formula would be calculated for each target separately, so without reset, the ability variable value will increase with each calculation.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.