This guide provides practical examples of formulas you can use with the Math Automation feature to create various effects. Feel free to copy these formulas and adapt them to your own projects.

Basic oscillations

Simple sine wave

sin(100t)

Creates a smooth wave that oscillates between -1 and 1.

Controlled sine wave

sin(t * u1) * u2

Use u1 to control the frequency (speed) and u2 to control the amplitude (size) of the wave.

Cosine wave

cos(t)

Similar to sine wave but starts at its maximum value.

Bouncing effect

abs(sin(t))

Creates a bouncing effect between 0 and 1.

Sawtooth wave

(t Mod 1) * 2 - 1

Creates a sawtooth pattern that rises linearly and then drops suddenly.

Square wave

sgn(sin(500t))

Creates a square wave that alternates between -1 and 1.

Audio-reactive formulas

Basic audio reaction

a / m

Simple audio reactivity normalized between 0 and 1.

Smooth audio reaction

p * 0.9 + (a / m) * 0.1

Smooth audio reaction that avoids sudden jumps by blending with the previous value.

Time-based effects

Fade in

min(t / 5, 1)

Gradually increases from 0 to 1 over 5 seconds, then stays at 1.

Accelerating value

t * t / 100

Value that increases at an accelerating rate (adjust the divisor to control speed).

Random and noise effects

Random noise

noise(t, 42)

Creates smooth random movement (change the seed value 42 for different patterns). Between -1 and 1

Slower noise

noise(t * 0.1, 727)

Slower, more gradual random movement.

Combining functions

Modulated wave

sin(100t) * cos(200t)

Creates a wave pattern that varies in amplitude.

Multi-frequency wave

sin(100t) * 0.5 + sin(300t) * 0.3 + sin(500t) * 0.2

Combines sine waves of different frequencies for a more complex pattern.

Practical applications

Rotation effect

t * 90

Constant rotation at 90 degrees per second (good for rotation properties).

Camera shake

noise(t, 42) * 50

Random camera shake effect (good for position properties). Use different seeds for different axis.

Value cycling

floor((t Mod 5) / 1)

Cycles through values 0-4 every 5 seconds (good for select controllers).

Chaining Math

Every Math automation has the user variables u1 through u5. You can automate them with other Math automations, thus creating very complex chains of operation.

Tips for creating your own formulas

  • Start simple: Begin with basic functions like sin(t) and gradually add complexity
  • Use user variables: Utilize u1-u5 to make your formulas adjustable without editing them
  • Normalize values: Keep values in appropriate ranges for your properties
  • Combine functions: Mix different functions for more interesting effects
  • Test incrementally: Add one component at a time and test to understand how each part affects the result

Debugging formulas

Use the cons(x) function to print values to the browser console while your animation is running. For example, cons(sin(t)) will return the sine value but also print it to the console for debugging.

Remapping values

Use the linear(input, inputMin, inputMax, outputMin, outputMax) function to remap values from one range to another. For example, linear(sin(t), -1, 1, 0, 100) remaps a sine wave from -1,1 to 0,100.