I love the new formula feature for setting variables, but there is one issue I have encountered. I have a battle scene where the player attacks an enemy, and if the attack hits, the enemy's health value is supposed to decrease by the player's attack value.
Before 1.30, I just used placeholder numbers and used the action variable : set with the increase by method to increase the enemyhealth variable by -5, or what have you. This worked fine.
Now, I'm trying to incorporate the attack variable into this formula. My action is now variable : set, the variable is enemyhealth, and the method is formula, since I can't type a formula in the "increase by value" field. So assuming enemyhealth is [var:1] and attack is [var:2], I have the formula set up as enemyhealth = [var:1] - [var:2].
This action works fine the first time it is used. So lets say I have initially set the enemyhealth variable to 20 in the variables manager, and attack is set at 5. When the action is first run, I followed the variable's value in the persistent engine inspector and the enemyhealth variable drops to 15, as expected.
However, when it is run a second time, the value will stay at 15. Nowhere in this scene does the enemyhealth variable get reset, so I have no idea why it isn't working the same way when run after the first time. My only conclusion is that when the variable : set action is run the second time, the [var:1] token is understood to mean the initial enemyhealth value, and not the enemyhealth value that was changed after the action was run the first time.
Is that the problem? Anyone know of a way to fix this problem? Thanks!
Edit: Apparently this also happens when trying to set variables as formulas in menu/inv actionlists too. Even further, after the action has been run once, the variable token (i.e. [var:1]) will be replaced with the value of the variable obtained at that time. This shows up in the inspector as the number instead of the token, even after the game has been stopped.
Comments