How it works...

We are using Unity's Transform.Rotate() function in this recipe. It allows rotating a transform around any given axis. It rotates the object the number of degrees we set as the function's parameter. We are using Time.deltatime to rotate the object X degrees per second. This function also has the space parameter, which lets us make a rotation in world or local space. The rest is handled by the hierarchy setup (WindmillWings being parented to the Windmill game object).

Using this method can save us a lot of time tweaking animations for simple rotating objects. What's more, we can still use Animation View to create an animation of the public float rotationSpeed parameter of our script. This way we can control the changes of rotation speed with a very simple animation clip, instead of animating the whole transform.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.191.233