We can use mathematical formulas to create interesting-looking animations. We are going to use this concept to make an endless curve animation with the Mathf.Sin() and Mathf.Cos() functions.
Using math to animate an object
Getting ready
We don't need anything special for this recipe. We are going to create it from scratch in Unity. You may also download the provided example project. Open the Chapter 10 Miscellaneous\Recipe 01 Using math to animate an object directory and load the Example.unity scene there. If you run the game, you will see the finished effect—a curve animated with the Mathf.Sin() and Mathf.Cos() functions:
Final effect—curve animated with the Mathf.Sin() and Mathf.Cos...