This can’t be that hard but I can’t find it anywhere.
I want to increment a number between 1-10, and if it increments to 11 it just wraps back to 1 instead. I’ve been doing it manually with if statements, and there has to be an easier way.
This can’t be that hard but I can’t find it anywhere.
I want to increment a number between 1-10, and if it increments to 11 it just wraps back to 1 instead. I’ve been doing it manually with if statements, and there has to be an easier way.
I think it’s called modulo, use a percentage symbol wraps the number :
#pragma strict
function Start()
{
for ( var i : int = 0; i < 50; i ++ )
{
Debug.Log( i + " index : wrapped by 10 = " + i % 10 );
}
}
so here the example is
i % 10
experiment and see =]