Reader small image

You're reading from  Unity 5.x Animation Cookbook

Product typeBook
Published inMay 2016
Reading LevelExpert
PublisherPackt
ISBN-139781785883910
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Maciej Szczesnik
Maciej Szczesnik
author image
Maciej Szczesnik

Not interested. Too busy with current game project. Source: Linkedin.
Read more about Maciej Szczesnik

Right arrow

Using math to animate an object


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.

 

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() functions

How to do it...

To use math for animating a curve, follow these steps:

  1. Create an empty game object.
  2. Add a Line Renderer component to it.
  3. Create a new material of your liking and assign it to the Line Renderer.
  4. Make sure the Use World Space option in the Line renderer component is not selected (we will use...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Unity 5.x Animation Cookbook
Published in: May 2016Publisher: PacktISBN-13: 9781785883910

Author (1)

author image
Maciej Szczesnik

Not interested. Too busy with current game project. Source: Linkedin.
Read more about Maciej Szczesnik