|
What am I doing wrong here? I just need to var checker to have no decimals.... var checker = 0; var checkerSpeed : float = .03; Thank you!
(comments are locked)
|
|
Mathf.FloorToInt returns zero because deltaTime is a small number. Do it this way: Is there another way other than creating a new variable? I have many timers and if each already have 2 vars, well, adding a third for each just seems like too much. Is there any way to do this with one line of code?
May 31 '11 at 07:03 AM
superventure
If you want the checker variable to have no decimals, you MUST have a 3rd var (a float to accumulate the small increments). As an alternative, you can declare checker as a float, accumulate increments on it and read its integer part when needed with Mathf.Floor - but this approach will be more expensive if you need this value more than once in your function. If you're thinking about performance, declare your variables as private unless you really need them to appear in the Inspector. Declare also each variable's type - it usually doesn't impact performance, but avoid wrong type inference by the compiler, a very frequent headache cause.
May 31 '11 at 01:11 PM
aldonaletto
(comments are locked)
|
|
You want checker to go up at intervals? (As an aside, there's never any point to multiplying something by 1. Something * 1 = something.)
(comments are locked)
|
|
You can't actually compare real numbers to integers, so just stick with one or the other. If you using the reals, you'll have to use Mathf.Floor or something similar.
(comments are locked)
|

note, I am using Js
parseInt() was what I looking for, for anyone else.