Skip to content

Instantly share code, notes, and snippets.

@luke161
Created December 26, 2016 20:46
Show Gist options
  • Save luke161/f09f2d58f4e7c5fd0464514f6c211311 to your computer and use it in GitHub Desktop.
Save luke161/f09f2d58f4e7c5fd0464514f6c211311 to your computer and use it in GitHub Desktop.
Function for generating a triangle wave between -1 and 1 in Unity C#
public static float TriangleWave(float x)
{
return UnityEngine.Mathf.Abs((x%4)-2)-1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment