- Home /
Range repeat? like 50 to 100 then back to 50
i'm not sure if this was already asked before Mathf.Repeat always start at zero how do i make it start on what number i want?
noob question
textAtlasScript.textureIndex=(int)$$anonymous$$athf.Repeat (Time.time*Time$$anonymous$$ultiplier, 100); this code currently does is index 1 to 100 but i want to start at a different index or number
Answer by Peter G · Sep 15, 2013 at 06:06 PM
You should just be able to add the initial value to the result of Mathf.Repeat()
var answer = 50f + Mathf.Repeat( Time.time * TimeMultiplier , 50);
it kinda worked when i print it but when applied it to textAtlasScript.textureIndex=(int)answer; it was out of range weird
it did start at 50
That's a problem with something else. This code isn't indexing anything so it's a problem in textAtlasScript
. It's probably one of the endpoints. Are you trying to include both 50 and 100? trying to include 100 but not 50 i.e. (50,100] in interval notation. If that's the goal, change the starting index to 51.
if only repeat can do this $$anonymous$$athf.Repeat(timer,startpoint,endpoint) ins$$anonymous$$d of starting from zero to length i needed both ends to be adjustable e.g var start = 5; var end = 10; i think this is what i really want the result to be 5,6,7,8,9,10,5,6,7,8,9,10,5,6,7,8,9,10 i know you can do this in a for loop and an if statement i just want to know if repeat can do this i guess the length in repeat means the Distance NOT the End Point thanks for answering!