Interpolating Integers
ADSentertainment
Member Posts: 397
I have two attributes, one attribute that stores a certain value, and another that interpolates towards that number. They're both integer attributes, but when the interpolator interpolates to the value, I'm getting a bunch of decimals when it does so until it reaches the value. Does anyone know why it does that and/or how to fix it? Thank you!
Having trouble with your game? Sounds like a personal problem.
Comments
*or ceil() or prec()
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
So it's perfectly possible to store the number 3 as an integer attribute but still extract it and - for example - chop it in half to get 1.5 (a non-integer number), the fact that it was *stored* as an integer doesn't impart some quality to the number that it carries with it from then onwards.
Once a number is out of its 'integer' or 'real' or 'angle' shaped storage box it is just a number, for example if we were to pull a number 5 out of each of those different sorts of 'storage boxes' we wouldn't have three different sorts of number 5, they would all just be 5.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Aaaah, alright, thank you for the explanation!
Having trouble with your game? Sounds like a personal problem.
Having trouble with your game? Sounds like a personal problem.
For instance floor rounds a number down:
Floor (24.58) = 24
Floor (1.6) = 1
Floor (398.22434) = 398
Floor (17.9) = 17
etc etc
'Ceil' rounds a number up:
Ceil (24.58) = 25
Ceil (1.6) = 2
Ceil (398.22434) = 399
Ceil (17.9) = 18
'Prec' lets you define how many decimal points you want:
Prec (398.22434,1) = 398.2
Prec (398.22434,2) = 398.22
Prec (398.22434,3) = 398.224
Prec (398.22434,4) = 398.2243
Having trouble with your game? Sounds like a personal problem.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User