I have a variable on my script which is a : int. Just wondering if its possible, that instead of having a value - its just infinity?
Thanks
I have a variable on my script which is a : int. Just wondering if its possible, that instead of having a value - its just infinity?
Thanks
Not with ints. Floats can use Mathf.Infinity.
Integers do not have a 'infinity' value. Once an integer is greater than max value it will wrap around to the minimum value. Here is a (C#) example:
int temp = int.MaxValue;
temp += 1;
print("temp = " + temp);
Output:
temp = -2147483648
Without an example, it is a little hard to guage what you are trying to do so here are a few examples you could try:-
Your could use a boolean which can be set true or false. You could then do a loop like so
` var isMoving:Boolean = true; // Loop endlessley while(isMoving) { // Do some stuff forever } `
You should look at Unitys built in Update function which loops forever anyway: http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Update.html
Finally, you can use floats to achieve this. Take a look at Mathf.Infinity.
@oliver-jones
How about use a float instead so you can use Mathf.Infinity?
To simulate an integer, you can restrict the float to its ceiling value by using Mathf.Ceiling(float) in an OnValidate() function.
Info on OnValidate(): Unity - Scripting API: MonoBehaviour.OnValidate()