ExtraBlender — UnityGameDebut
Blender & Extra Animation — Episode #09
Hi, in the previous post we get the enemies shooting at us randomly (check for the previous code in Github). Now let’s make them fall when hit by a shot.
Now, itttt’ssss timmmme! ops… It’ssss fightttt timmmme!
…Of Blender animation. Sadly the ToonSoldier pack does not come with a die animation 😑. We will use Blender for this purpose 😆. Let’s make our own anime…
Actually I would like to see the enemy fall from the top of the tower. but I have not got it yet … 😒 you reader can try it and once you’ve got please send your solution … publish the result too! so in this manner, we learn from each other. This is the strength of opensource, right?
There we go!
Step #01 — Open Unity and in ToonSoldier_demo > Animation you’ve got: idle, run, shoot and shoot bust animation…where is die or fall animation? nope…but, here is the animation you needed most: I call it to fall:
Download from my Google Drive the file fall_v6.fbx
Save it in your Asset>ToonSoldiers>Animation folder;
Step #02 — To start-up let’s create a vector to memorize the position of the soldier. Open Soldier.cs and declare this property:
//the actual soldier's positionVector3 mStartPos = Vector3.zero;
Step #03 — In the Soldier.Awake() type right below gameObject mEnemy:
//Get the enemy actual gameObjectmEnemy = transform.GetChild(0).gameObject;//Start soldier's positionmStartPos = mEnemy.transform.position;
Step #04 — In the Soldier.Activate() type:
mAnimator.SetBool("shoot", true);mEnemy.transform.position = mStartPos;
Step #05 — How to trigger fall animation? We need to register as humanoid anime first; just do it:
Double click the fall animation, in Inspector click 1) Rig, 2) choose Humanoid 3) click apply and then Configure, click save; a new popup appears, 4) click Pose > 5) Reset and them 6) click Force T-Pose, and 7) finally Apply and 8) Done, you finished to set up the animation to work in mechanism Unity System;
Step #06 — Go to Animator, 1) Drag n’ drop fall_v6 to the flow diagram, 2) Make a transition from Any State to fall, deselect Has Exit Time and 3) then another transition from fall to idle (resurrection); 4) create a trigger and name it fall, 5) select Any State > fall Transition and set Conditions to fall and 6) make some adjustment; there you go! the enemy will fall sideways and resuscitate (yes, believe it or not?).
Run and confirm if everything is working…
Step #07 —here is the code till here: Github
In the final post, we will make the HUD and rifle’s sound effects! Do not miss this great event! This is your 🎯, right?
Till there, bye!
Thanks for your visit! Stay tuned!