Profile image

Arduino-esque Looping in FT with Variables

67.1k SnoWFLakE0s  3.2 years ago

Hello everyone,

One of the most important things to note about the new variables feature is that they can reference themselves. What's most interesting about all this is that the entire set of variables is evaluated every physics cycle in the game, and this can be used to our advantage in order to complete tasks not unlike loops in programming languages.

Particularly, if you've had any experience with Arduinos, you'll know about void loop()--FT variables are very similar to that now in that sense, and this can be used to make some interesting things happen. For example, if we:

  1. Initialize the variable i and increment it by doing i = i + 1
  2. Have another variable x on x = x + 1, with an activationGroup of i < 5

You will result in x = 4 in almost instantaneously but not instantly, as the physics updates go through and increment the variables by 1 each update.

I just found the concept fascinating, and this exact structure would have some utility in building an expression that times things at a very specific rate.