Forum rules - please read before posting.

Set Variables via Formula with floats smaller than 1

KouKou
edited November 2020 in Technical Q&A

Hello,

I am currently running into a problem, to which I just can't find a solution or workaround.

I want to set variables (all of them are floats) in the ActionLists using the "formula-method" using two different variables and adding them / multiplying them.
For example [var:1] is 0 and [var:2] is 0.5. As soon as I write [var:1] + [var:2] the console tells me "Cannot compute formula: 0,5 + 0".

The scenario is, that var:1 is the playerscore and var:2 is the bonus. So I tried just using numbers 10times as big as bonus-numbers and first multiplying the playerscore by 10, then adding the two variables and then dividing them by 10 again. This works for the first scenario, but of course the result for the player score then is 0,5 and if I run the action-list with a playerscore of 0,5 again the console tells me "Cannot compute formula 0,5 * 10".

So the problem seems to be, that it can't calculate with floats smaller than 1. Is that correct? Or am I doing something wrong?

Thank you so much for anyones help!

Comments

  • Shouldn't be an issue - I've just tested two Floats of values 0 and 0.5, and it added them up OK.

    What are your AC and Unity versions, what platform are you working with? If you can share screenshots to show exactly how your variables are set up and used, that will be welcome - as I can't seem to reproduce this otherwise.

  • KouKou
    edited November 2020

    Thank you for looking at the problem: Unity-Version is 2019.4.14f1 and AC is v1.72.4 I am using a PC and also making a pc build.




    And I am already sorry, if I am doing something incredibly stupid. I am wondering, whether is has anything to do, with me using the variable in the formula, that I am trying to set...

  • edited November 2020

    No apologies necessary - the way you've set things up all looks good.

    Using variable tokens inside the formula should work - though try inserting the values directly into the box, just to test, i.e. "0 + 0.5".

    The key thing I'm seeing is that it seems to be replacing variable 7's decimal point with a comma - 0,5 instead of 0.5. I suspect that may be the cause.

    A search of Unity's forums suggests that this may be to do with the language your Mono instance relies on. See this thread - though Unity claim to have since fixed it, you may need to follow the advice of Alexey / gresolio and make use of a custom script to reset it.

  • KouKou
    edited November 2020

    You were absolutely right! I wouldn't have had any idea how to even search for the problem, so thank you a million times! Just having a small other technical question here... I can't seem to find a donate button on this page! Been using your addon massivly in the last years and bought it 50% off - so now it feels like a steal:)

    btw, don't know if of interest: running
    PlayerScore = AC.GlobalVariables.GetFloatValue(1) + AC.GlobalVariables.GetFloatValue(7);
    Debug.Log(PlayerScore);

    worked just fine even before the fix.

  • No worries - reviews are always welcome, though.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.