-
Save previous variable value – expression
Hi, how can I store a previous value in a variable, the problem I have If I do: “var vPre = 0;” then for every frame it will re-defines it to 0, I would want to make is so if vRan is bigger than vPre then make vPre the value of vRan, so if it works vPre should only be able to get bigger over time.
And I think If i define the variable inside an “if statement” it wont be a global variable?
Alternatively is it possible to write the result of a variable on to a expression control so It can be used to compare against next frame, when i try I get “it is read-only”
Hope it makes sense.
Version 1:
var vPre;
var vRan = (random()*100);if (vPre == undefined){ vPre = vRan};
if (vRan > vPre ){ vPre = vRan};vPre;
Version 2:
var vRan = (random()*100);if (vPre == undefined){ var vPre = 0};
if (vRan > vPre ){ vPre = vRan};vPre;
Thanks.