

The green arrow indicates the path’s beginning and the red arrow indicates its end.Ĭlick Custom Path. The path chosen appears as a dotted line on the selected object or text object. On the Animations tab, in the Animations group, under Motion Paths, do one of the following:Ĭlick Lines, Arcs, Turns, Shapes, or Loops. The path that you apply is followed by the center of the object or text bullet. To do that, we will use the other animation view: the “Animator”, which represents the “Animator Controller” states machine of an object.Click the object or text to which you want to add a motion path.
#Animations how to#
In the next chapter, we will see how to combine the different animations and call them with our scripts. Now, we need to integrate them in the game. We have learned how to create some animation clips for an object.

Observe the “Mouth” (another image) and “Bonus” (enabled) children. It should be hidden most of the time (like in the Idle animation). This object will serve to display an additional image when we want. In your “Boss” Prefab, add a new sprite child called “Bonus”. Just make sure to name the clips “Boss_Attack” and “Boss_Hit”. It’s a good opportunity to test what you have learned before. Now, it’s time for you to experiment! Here’s what you should have in the end:įor these animations, we will give an example of what you may achieve, but we recommend you to have fun and make your own.
#Animations update#
Update the collider size to make it fit the animation.Change the sprite (of a “Sprite Renderer”).You can update the position ( do not do that on the container).We just made an animation using the rotation, but you can update every property of the object and its children. The animation doesn’t look the same: it’s way faster with a pause between loops. For example, if we mess the whole thing a bit: It will update the keyframes and their associated values. We can play with the curve by dragging the points. Our current idle animation is looking like a regular sinusoidal currently: This is a special tab that you can toggle in the bottom left corner of the “Animation” view: You have two solutions: You can add other keyframes in between, or play with the Curves. However, you may want a non-linear interpolation (starting fast and ending slowly for example). Playing with curvesīetween each keyframe, Unity uses a linear interpolation to deduce the intermediate values. Here we are working on the parent because we want everything to rotate together, but maybe we should have add an empty parent object on top of everything that is never animated.

Most of the time, you want to change the children properties and not the container. We’ve got:Ĭhanging a property of the “Boss” object: if you change a property of the parent object (the “Boss” object here), be extremely vigilant, especially with the “Position”.įor instance, if you change the “Position” of the “Boss” object in an animation, its real position in the scene is going to be changed for the one in the animation each time it is played. For each one, add a “Sprite Renderer” and select the appropriate image (body, eye or mouth).Ĭhange their position to get something like this:įor example, the left eye game object has been positioned with the mouse in the editor. That is why we don’t have a “Sprite Renderer” here.Ĭreate 4 empty game objects as children of the “Boss” object. This object does not display anything.Add a “Box collider 2D” with a size of (6, 6).Add a “Rigidbody 2D” with no gravity/fixed angles.To have the proper configuration, create an empty game object. Use the automatic slicing feature (a size of 32 should be fine): Set its “Sprite Mode” to “Multiple” in the “Inspector”.The sprite is made of multiple images: a body, the eyes and some additional stuffs. There are some differences, especially about components access, but the features are the same. Warning: this part of the tutorial has not been updated to Unity 5.
