I know it sounds like a dumb question, but it’s been bothering me for some time now.
I know how to use a for loop, but I don’t know how to use it with Unity’s time scale. My problem is this:
I need to do a block of code for randMovementTime which is a float variable created and assigned a Random.Range value in the Awake function. So the for loop would look like this:
for (i = 0; i > randMovementTime; statement3)
{
// Block of code goes here...
}
I don’t know how to increment i in statement 3 at the rate of Unity’s time scale to make it equal randMovementTime.
To put it simply: I want to know how to do a for loop for a certain amount of time.
i would have to be time, but any version of time would be the time since level load or time since startup, but I need the time since the for loop was last triggered, so i needs to start at 0 and be incremented at the rate of the time since the for loop was last triggered.
Any help is greatly appreciated!
EDIT: I am using this for loop in the Update function, so no coroutines.
- Chris