How would one interpolate a score with whole numbers only?
Tiny_Ideas
Member Posts: 326
Hello the very helpful forums,
I was playing around with some cool ways to make a game more user engagement. Is there away to interpolate a score only going up in whole numbers,
Here is what I tried and expanded on:
One actor which displays the attribute game.SCORE
Within that actor I have an interpolation behaviour that interpolates game.SCORE to 300 (from zero) in one second.
My issue with this that the actor displays decimals as well, so instead of going up , 1,2,3,4,5,6
It goes up something like this, 1.5,2.35,4.123 ect
I first thought this was because I was using an integer attribute, but after trying the index attribute, one that won't even accept decimals, it still showed decimals while going to 300.
Is there a way to get rid if the decimals, a function I should be placing within the display text behaviour?
Thanks in advance
I was playing around with some cool ways to make a game more user engagement. Is there away to interpolate a score only going up in whole numbers,
Here is what I tried and expanded on:
One actor which displays the attribute game.SCORE
Within that actor I have an interpolation behaviour that interpolates game.SCORE to 300 (from zero) in one second.
My issue with this that the actor displays decimals as well, so instead of going up , 1,2,3,4,5,6
It goes up something like this, 1.5,2.35,4.123 ect
I first thought this was because I was using an integer attribute, but after trying the index attribute, one that won't even accept decimals, it still showed decimals while going to 300.
Is there a way to get rid if the decimals, a function I should be placing within the display text behaviour?
Thanks in advance
Comments
Try 'floor', 'ceil' or 'prec'.
Let say game.SCORE = 18.7654
In this case floor(game.SCORE) will give you 18
Whereas ceil(game.SCORE) will give you 19
And prec(game.SCORE,0) will also give you 19
floor rounds numbers down, ceil rounds number up, prec (precision) lets you define how many decimal points the number holds so prec (18.7654,2) will give you 18.76 - and prec(18.7654,1) will give you 18.7
Apologies for the late reply, very helpful thanks, wouldn't think I would have had to do that with an index attribute though.
And cheers for taking the time to make a quick demo.
Yeah, agreed, intuitively you'd think 'index' would only return integers, but it's really the interpolate behaviour that's doing the work here, you're not actually incrementing the 'index' attribute, it is just the starting value for the interpolate behaviour.