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 the Rotate() function to animate an object


In this recipe, we will use the Transform.Rotate() function to create an infinite looping animation of a windmill. We could make the same with the Animation View, but sometimes writing a simple script means much less effort than creating a key frame animation.

Getting ready

We need a few models we can rotate in this recipe. As an example, we will use a windmill. It is composed of three game objects: WindmillBase, which is the root of the whole windmill, Windmill which is parented to the WindmillBase, and WindmillWings which is parented to the Windmill. The Windmill game object itself can rotate in the Y axis. The WindmillWings game object can rotate in its local Z axis.

Windmill hierarchy

You can download the example project and go to the Chapter 10 Miscellaneous\Recipe 03 Using the Rotate function to animate an object directory. Open the Example.unity scene there and play the game. You will see the windmill rotating around the Y axis and its...

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