Repeating Sequences

One very useful variable is SequenceInstance.Loop. So long as this boolean is set to true then the sequence will loop over to the first effect after reaching the last effect.

Demo #3 uses this line in order to create looping behavior:

Movement.Run(faceRandom).Loop = true;

Movement.Run returns the SequenceInstance. We don’t store the SequenceInstance in this case even though we could, we just change the Loop field to true. If nothing else was going on then this would create a sequence that would never end, but it doesn’t in this case because we’ve set Effect.ContinueIf so it can exit the sequence as soon as a variable is set to true. This is another way to run a sequence, it’s a bit like defining a while loop with while(true) and then putting a break statement in the loop somewhere.

Another way to use SequenceInstance.Loop would be to store the SequenceInstance object in some manager script and then set it to false from your manager script when something changed. This might be useful if, for example, you wanted to put some glittery sparkles around an important object in your scene. Once the user picked up the object you could simply set Loop to false. That way the sparkles would hang around for a little bit after you picked up the item rather than instantly going away.