unity3d: 3. Animation on demand

HI !!! I will show you today how to make animation on demand, animation is used in FPS games, when an NPC hasn’t life points, then is executing death animation.

Now we will do a different animation than death animation on demand, but it will be based on the same principles. We will make an example animation that when our object, which we control, eg. A ball will hit a cube, then this cube will fly up and come back, the simplest example that may you could easily understand how to make animation on demand, we will have to create two animations, one that won’t do anything and second that will be move the object up and down, if you do not know how to create an animation
click here

So, first create an animation, do nothing in animation options and save it

Then create another animation, add add property transform then position, then set the animation like this:

Of course, you can create the second animation in way you want, I just did it for educational purposes.

Once you have created this animation, go to the “Animator” window next to the “Game” window, these rectangles, apart from “Any State” and “Entry”, are the animations you have created. On the left side of the “parameters” window, press this small plus and select “Trigger“, name it as you want, then right-click on the animation rectangle that symbolized idle, and select “Make Transition” and aim the arrow on the second animation, you have to do this because the animation will go from idle to float up, with the second animation you do the same, then press the arrow that points to the animation that in my case is floating up and down and press this plus on the bottom right and give it the name as you gave to that parameter “Trigger”.

The whole looks like this:

I to named the animation of inaction “anima” and the second “anima1”. And all of this now just need to assign a very simple script below to the object that we want to animate and assign the tag “Player” to the object we control, to assign the tag click on the object you control and click on the top “Tag” window and select the tag “Player”.

This content also you can find on steemit: https://steemit.com/unity3d/@slawas/unity3d-3-animation-on-demand

And on medium: https://medium.com/@sawomirkowalski/unity3d-3-animation-on-demand-985c1110c3e6

That’s all I wanted to describe today, hold on !!!!!

If that post was useful for you share it with your friends :)

Post a comment

Notify about