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?
    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!
  • 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.
    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!
  • Yes, I understand, except that the value of this particular variable was never previously altered. At least, not in selected form. I've used a local variable by the same name in other formulas, none of which are tied in any way to this formula where I'm currently attempting to add to a selected value. In any case, local and selected variables shouldn't be contaminating each other's values, regardless of whether they share the same name.
  • No, local and selected variables don't influence each other. One thing I could think of would be the ability being added to selected data twice, which would lead to increasing the variable twice as well ...
    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 didn't want to start a new thread for this recently discovered issue (though it's different from the one this thread was initially discussing) but I've noticed that, as of the recent update, Local Variables created in events via the 'Change Game Variables' node are not being passed to formulas. I noticed this while I was going back over my attack and damage events trying to figure out why they'd suddenly stopped working properly. Here's an example of how I confirmed the discrepancy:


    Step 1- Inside of an event, I create a 'Change Game Variables' node, make it local, give it the key 'Testing3476543' and set the value to 22.

    Step 2- I create a formula with a 'Check Game Variables Node' that checks the the value of 'Testing3476543'. If the value is 22, the formula sets its value to 777. Otherwise the value sets to 666.

    Step 3- Inside the event, I create another 'Change Game Variables' node, make it local again, make its key 'TestingTesting3476543', and set its value to equal the formula I just created.

    Step 4- Inside the event, I create a 'Variable To Variable' node that changes 'TestingTesting3476543' to an object variable of the same name, so that I can see the result on my character in a running game.

    Step 5- I read that the value of my test variable always comes up 666.



    This apparently holds true in the case of Selected Data as well. Here's an example of that:



    Step 1- Inside of an event, I select a piece of equipment and name it 'Armor'.

    Step 2- I create a formula with a single value node set to equal the float value of a variable attached to the piece of equipment that was previously selected inside my event. Specifically, The Value is set to 'Game Variable', the Variable Key is the name of the variable (Copied and pasted to perfection) as taken from the equipment piece, the Variable origin is 'Selected', the Selected Key Value Type is 'Value' and the value itself is set to 'Armor'.

    Step 3- I repeat the processes listed above noticing the same result: the variable's value isn't being picked up by the formula.

    Step 4- I go back to the formula and insert a Selected Data node set up just like the one in my event, giving it the same Selected Key: Armor.

    Step 5- I run my game, have my combatant attack something and it shows the variable's correct value assigned to the Object Variable. In other words, the node setup to read the variable and assign its value works properly, but the selected key, Armor, isn't being passed into the formula.


    Strangely, however, many variables are still passing through formulas and events without an issue. For example, one of my early events in the chain determines the type of attack that is being made as based on the user's weapon. to do this, it checks the hand that's being used as defined by another variable from a proceeding event, selects the corresponding equipment part and then assigns it the key, 'Wpn_User'. Then it does a bunch of other things before finally determining a value for certain variables like, 'Atk_AtkType_User' (Swing, Thrust, Bash, Lash, Punch, Kick, Poot:), and 'Atk_DamageType_User' (Cutting, Piercing, Spiked, Impact).

    Variables like those and others are referenced many times throughout my string of events, and are successfully passed to various formulas that use them in determining which string of numbers to plug into where, and they still appear to be functioning event now; I've tested and confirmed this in several spots. Yet others, like those I mentioned in the previous examples, are just sitting there like a bunch of useless log warts, not doing anything and not passing their values to the formula's that need them. What's up with that?
  • I'll check it out.
    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!
  • Hm, tested it and worked on my end. Since it works with other examples on your end, I'd guess it's either a typo in the variable key or due to floating point imprecision when doing the checks. To prevent imprecision in checks, use the Approximately check type instead of Is Equal when checking float values.
    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!
  • "Hm, tested it and worked on my end. Since it works with other examples on your end, I'd guess it's either a typo in the variable key or due to floating point imprecision when doing the checks. To prevent imprecision in checks, use the Approximately check type instead of Is Equal when checking float values."

    The value is an integer, so I don't think imprecision is the problem. That, and the value tests positive as being equal to zero. It's also not a typo issue; I've made certain all the letters and their cases align, and there's no extra space after the input. I've noticed that certain inputs, like variables, don't transfer properly after more than 1 degree of separation--an event called by an event that's called by an event doesn't seem to pass along it's changes up the ladder, and I'm thinking that might be the problem. When I create the variables and assign them a value in the initial event, it registers perfectly.
  • Tested it with a game event calling a global event and it worked fine. Make sure to enable sharing variables in the Call Global Event node if that's what you're using.
    Otherwise I'll need details on how your events are called, e.g. what type of event (game event, battle event) is calling which type of event and how?
    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!
  • No, no--Local Events, not Global. I don't want to make them global. I want/need to transfer Local events. Global events are always referencable, that's why I've little to no particular use for them 95% of the time.
  • There are no local events in ORK ... unless you're talking about starting a game event via event interaction, but this can only start another event via global events. So, I'd need details about your event calling setup to check out your use case and see if there's a bug or just a wrong setup :)
    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!
  • "There are no local events in ORK "

    Yes, it seems I blew a microchip there for a moment which caused me to read (and write) 'Event' as 'Variable'. It's fixed now. Sorry about that. Incidentally, the event in question here is actually a Battle Event called by another Battle Event. I could also just do the whole thing inside a string of formulas (which is how things were set up in my project's earlier stages), but it gets a little messy when you decide to change certain things around, or (Heaven forbid) add a new formula to the chain by copying another one that's high in the list, and then suddenly you're spending 20 minutes to move your newly copied formula up the line until it's with the rest of its group so that you don't end up with a sporadic mess of formulas connected all over the place. I prefer to do as much of my work as possible in events now, because they're modular.
  • Well, glad this is resolved :)
    It doesn't matter if it's a battle event or global event being called, make sure to enable sharing local variables or selected data if you want to use them in the called event.
    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.