My first attempts at mastering animation.
I decided to share my experience in creating animations for the very beginners. I am using Unity engine to create games. More advanced users use special animation programs such as Adobe Animate, Blender, Pencil2D Animation, etc. However, if you are just starting to use Unity, there are a couple of interesting methods you can use.
One of the first hacks is for rotating objects around their axis. For example, spinning a mill wheel, circular saw or a coin in the path of the hero.
To implement a simple rotation, you need to create a C# script or a Bolt graph (if you are using visual programming).
In the Update method, write this code:
transform.Rotate (0, speed * Time.deltaTime, 0, 0);
We take the position of the item this script is attached to and call its built-in rotation method. We tell this method that we need to rotate the object vertically (along the Y axis).
Speed can be set as a public method to change the value right in the editor. I would advise you to do this like public value, because when you change the speed directly in the script, you will change the speed of all objects to which this script is attached. If you still need the speed to change simultaneously for all objects, then change the standard speed from 0 to the desired value, or create one instance of a saw or mill with this script and save it to the Prefab.
After creating the script, attach it to the desired object and enjoy how cool you are))
The next post will be about creating animations using the built-in Unity animation component. For interest, I’ll add an example implementation from another project.
See you soon )))
Author: Bogdan Shuplyak Updated 5 months ago