Adding Animations | Blend Trees, Layers, & Animation Rigging - 3rd Person Shooter - Unity Tutorial
Тәжірибелік нұсқаулар және стиль
Learn how to add animations to your characters via Mixamo (free characters and animations) and the Animator component. We will learn how to add pre-existing animations and also add dynamic and procedural animations using Unity's Animation Rigging Package.
ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓
sam-yam.itch.io/samyam-full-s...
First, we'll choose a model and animation in Mixamo, import it into Unity and set up a Humanoid rig. From there we will add a Strafe animation from Unity's Standard Assets on Github and use a Blend Tree to easily and smoothly blend between the different strafing directions. For our animation scripting, we will be doing a cross fade to our jumping animation as a sort of trigger.
Then, we will download and use the Animation Rigging package to dynamically grip the gun with the character's hands and a Two Bone constraint. We will also have the player body aim up and down with a Multi Aim Constraint to aim at a target direction.
Once we set up dynamic animations, we will add a recoil animation which our set up Animation Rigging will help with. The animation is added in a separate layer to have different running and recoil animations playing at the same time.
►🔫 3rd Person Shooter Controller with Cinemachine & Input System - Unity Tutorial 🔫
• How to make a 3rd Pers...
►💻 Project Files Available on Patreon 💻
/ 53254441
►🔗 Relevant Video Links 🔗
www.mixamo.com/
github.com/Unity-Technologies...
opengameart.org/content/3d-lo...
docs.unity3d.com/Packages/com...
Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won't cost you any money, they will help me fund my development projects while recommending great assets!
😎 Cool Unity Assets 😎
ᐅPeek - Editor Toolkit: assetstore.unity.com/packages...
ᐅEditor Console Pro: assetstore.unity.com/packages...
ᐅRainbow Folders 2: assetstore.unity.com/packages...
🤝 Support Me 🤝
Patreon: / samyg
Donate: ko-fi.com/samyam
►⏱️ Timestamps ⏱️
0:00 Intro
1:07 Previous Video
1:25 Mixamo Download Model
4:29 Set up Humanoid Model
11:26 Animator Component
13:01 Download Strafe Animation
13:47 Set up Blend Tree
23:30 Smooth Damp Input System Values
26:48 Animator Cross Fade
30:43 Animation Rigging Overview
35:49 Two Bone Constraint - Right Hand
43:38 Two Bone Constraint - Left Hand
46:46 Multi-Aim Constraint to Aim Body & Head
51:36 Change Aim Target in Script
53:06 Reparent Gun under Mixamo Spine
54:51 Small Player Shoot Glitch Fix
55:19 Recoil Animation
57:48 Layers
1:07:25 Add Limit to Multi-Aim Constraint
1:08:00 Outro
💖💖THANK YOU TO ALL MY PATRONS FOR MAKING THIS VIDEO POSSIBLE💖💖
❯❯❯ My Links ❮❮❮
💗 Patreon 💗
/ samyg
💬 Discord Server 💬
/ discord
🐦 Twitter 🐦
/ samyam_utube
📚 Facebook 📚
/ samyam.youtube
🎵 Music 🎵
Ambient Gold
streambeats.com
👍 Like and Subscribe! 👍
🖥️ Computer Setup 🖥️
*As an Amazon Associate I earn from qualifying purchases.
www.amazon.com/shop/samyam
#madewithunity #gamedev #unity
Пікірлер: 163
🔫 Previous Video --> 3rd Person Shooter Controller with Cinemachine & Input System - Unity Tutorial 🔫 kzread.info/dash/bejne/hZl2p9iGYt2zoLw.html
@ablgr511
Жыл бұрын
👍👍👍👍👍👍👍👍
I really enjoyed this video! It took me several days of approaching the different chapters, but after I got through I have learned several useful tricks for animating my character! This is put together very well, and is currently the hardest coding tutorial I've gone through so far!
What a great video! Congratulations Sam, you cover almost everything I need to know about animation in Unity. Thanks a lot!
@samyam
2 жыл бұрын
Awesome!
some tips: if you open the animation window with a transform in the skeleton hierarchy selected, you can click the "preview" button to preview the rig and effectors to make positioning your effectors easier [no need to click run]. also, if you place the end bone transform in the hierarchy and right click on the component you can choose to auto populate the fields in your ik component - it'll create child objects to use as your target and hint.
I know how exhausting coding an explaining your code + teaching all the same time can be. I am so grateful for your content. You are seriously awesome.
@samyam
2 жыл бұрын
Yay!! So happy to help 😄
This blend tree thingy really makes my life so much easier! Thank you!
I can't believe tutorials like this are available for free, this is so meticulous and educational! :D If anyone wants to import their own character and have the textures work as well, in both mixamo and blender here's how I did it: 1. Export the model in standard T-Pose as fbx with these settings 1.1 Limit to Selected Objects 1.2 Apply Scalings -> FBX Units Scale 1.3 Apply Transform 2. Make a .zip file with the fbx file and your uv pallette, do the steps in Mixamo as usual.
Now this is a great, informative, useful tutorial which wil take your ratings higher. Thanks a million!
@samyam
2 жыл бұрын
Thank you!
this is really good- thank you for creating this, super helpful and exactly what I was hoping to find.
Thanks for the tutorial. Got a shield working in my own project the way I envisioned and a little more.
Thanks, this is what I have been waiting for!
Superb, the best tutorial I could find that also covers input system and cinemachine altogether !!! *Thumbs up*
@samyam
2 жыл бұрын
Thank you so much! :)
Having done the Official Unity training videos to prep for the Pro Artist cert - I learned more from this video than hours of work with the official curriculum.
@samyam
2 жыл бұрын
woohoo!!
Big shoutout for telling us the hotkeys as you're going, very helpful!
This is a good tutorial... These is actually what you do 80% similar to make a third person shooter...
thank you for this awesome video. Watched it from beginning to the end!
Can't wait to test this. Thank you. :)
Thank you for this. It had been surprisingly difficult to figure out exactly how to setup the overriding animation layers. It didn't occur to me that I could have the entry transition to an empty state.
This was just what I was looking for!
I ended up using layers with override, fixed the problem by key framing the arm rig weight with my shooting animation. Awesome video, Thanks!
Really great video. Thanks for putting this together!
@samyam
2 жыл бұрын
Thank you!
Your last video convinced me that 3rd person is doable and pivoted my proto thank you!
@samyam
2 жыл бұрын
yay!
This is something I am looking for and you make it easier
Great awesome video tutorial!
Awesome thank you! this is helping me with my math game i'm working on
Perfect stuff!!! Great channel! Thanks a lot!
Thanks!! I love you!
Marvellous. Thank you very much.
Finally some kind of actual tutorial
Hey Samyam love your Vids, nice chilled way of explaining things :)
@samyam
2 жыл бұрын
Thank you :)
Thank you so much! you re underrated.
@samyam
2 жыл бұрын
Thank you! 😄
great tutorial, very detailed
@samyam
2 жыл бұрын
Thanks!
Geez ! It took you more than an hour to do this video. Im gonna be here until the next week. PD: Nice video Sam
@samyam
2 жыл бұрын
thanks! :)
thank you, this is underrated
@samyam
2 жыл бұрын
Thanks! :)
Hey thanks for the mention!! Very much appreciated
@samyam
2 жыл бұрын
Oh wow! Thank you for your great video 😄
@bigshotstudioslive
2 жыл бұрын
@@samyam no problem at all I am about to join your discord if you don’t mind
@samyam
2 жыл бұрын
We’d be happy to have you!
tysm great video as always !
@samyam
2 жыл бұрын
Thanks!!
8:46 casually plowing through unity docs mid vid :) Great one, btw!
@samyam
2 жыл бұрын
😂 Thank you
thanks
Thank you:)
THank you SO MUCH! 😭😭
30:53 "Open up the Package Manager, wait 30 years", lol
Love you 💕💕 dear.
Great
You are doing great job dear, good explanation. Thanks.
@samyam
2 жыл бұрын
Thanks!
Tqqq this is what i wanted
The transform of the Aim Target in the Aim Rig keeps on jumping up and down, causing my character to glitch out. Any tips on how to deal with that? Awesome tutorial btw!!
Do you use Audacity to clear your audio? You have incredibly clear audio. If you do, what are your noise removal settings?
At 25:42, in the Vector3 move, you changed the input.x and input.y to currentAnimatorBlendVector.x and currentAnimatorBlendVector.y. Would you be willing to explain to me why you did this? I know that it changes something with the animation, but I don't quite understand why you did it and I like to understand the code that I write and how it works instead of just writing it and not knowing why it works. Love your tutorials though. Always amazing and super helpful!!
(Solved it but i'll let it sit if someone is in the same situation) Got a question somebody maybe can help me with. The vertical sensitivity on the mouselook is half the speed of what the horizontal is, noticed it around minute 2800 into the video and have been following from the first one. Maybe it will come up later in the video but if anybody knows id be most appreciative! And what a superb tutorial! Informative yet to the point! UPDATE: It was a simple oversight of a speed parameter at the virtual aim cameras aim component.
Hi! Since I didn't watch the whole thing yet, I would like to ask you some help. I'm having problems with the animation riggin package, it seems there is some kind of conflict between the rig builder and the mixamo animations, everytime I run the game my model sinks into the ground with no animation ( prior to applying the rig builder it worked perfectly). Any idea of what's going on? I'm new to this hahah Btw, I recently discovered your channel. Nice work, I'm suscribing ;)
Hey, After adding the animation rig if I try to move the character its upper body is completely rotating not its leg. And the upper body is slightly tilted to the left side.
where would u add the jog stop animations for run forward strafe left and right?
I realize this (awesome) video is a couple years old, but just incase, I have a question about the recoil animation causing my player to sink into the ground. When I record the animation, my character does sink into the floor. But it also does in the video so no big deal there. However, when the recoil animation plays, my character sinks into the floor as well. I’m not really sure how @samyam worked around this or avoided this? If anyone has a solution I would be grateful!
I created motion using blend tree 1D and assigned velocity as float. When I control with the keyboard, I made the adjustments, but when I take my hand off the key, the walking continues and the idle animation does not start. what could be the problem. thanks .
Thank you. Keep it up sister
the one issue i had with this process is that when i try to give the character a camera as a component (for multiplayer games) it will start spinning around like crazy, if i move the camera out it goes back to normal.
Nice video.,.
@samyam
2 жыл бұрын
Thanks!
How may I implement strafe movement in case when camera does not rotate with character ? So X and Z values of Animator also depend on character rotation ?
Hello! Really congrats for the videos! They are fantastics! Unfortunately I have a problem.. I cannot understand why but, when i try to make the recoil animation for some reason if i just try to change a little bit the pistol position it completely override the (Read Only) animations of the charatcer and it completely move my charatcher under the floor without his animations. The recoil animation on the upper body works but the character it stuck on the floor with his legs as if he were suspended in the air. It seems like the new animation of the weapon completely override the others.. giving the charatcher different position... You know why? UPDATE: I know what's the problem, but i don't know how to solve! The player inspector just suggested me the problem. The fact is that i'm trying to add a "generic" animation to a body that contains transform set to "Humanoid". How did you managed it??
Hi..Please why did you not make a multi-aim constraint for both hands to point to the screencenter point. U did it for the body and chest but the hands didnt point to the center....Codemonkey did it that way and Im just asking!! Or because in this very particular case the chest is facing the center o theres no need..
41:00 I noticed when you're not in playmode, you can preview the animations for the IK transforms and it'll work the same way as if you're modifying it in playmode. At least this way you won't have to copy the current transform, stop play test, paste transform, and then play test again.
@samyam
2 жыл бұрын
That's neat! Where would you click to preview the animation?
@MegaPortugueseman
2 жыл бұрын
This is the equivalent of browsing through forums for answers and find a SOLVED thread where the author edits the post by saying "Never mind I found the answer" with no extra comments.
@slavic_sloth
2 жыл бұрын
@@MegaPortugueseman Not even in the slightest. It's in the animation window. As mentioned, the "animations" in my original comment.
@slavic_sloth
2 жыл бұрын
@@samyam Check out the animation window. There's a preview button next to the red record button.
@MegaPortugueseman
2 жыл бұрын
@@slavic_sloth Thank you
Can u make a video on how to switch the weapon plz
Is it easy to maintain with different type of weapon? 2 hand, melee weapon?
Only thing that could be the issue with the layers is that the gun is not really part of the humanoid character animation. So additive makes more sense on that. Otherwise I'm unsure why it wouldn't work the other way. Thanks for that layer layout. i didn't think about calling it from script. I used a trigger and made default empty script run super fast so it would come out of it fast. but makes more sense to call it directly and return to the empty. i did it on a game jam. might go back and modify it. see if my punch mechanic looks better. Thanks. Wish there were more videos on layers. They are so useful, just not many use case tutorials on it.
@samyam
2 жыл бұрын
Thanks for your comment and glad you found the video helpful!
a possible reason why the "override" mode did not work is that it is better not to touch the green-red picture, but select all the necessary bones in the transform tab below. at least I still don't understand why this picture was needed but it never works
I am still struggling with the dopesheet... will come back to your new tutorial when I figure it out!
@samyam
2 жыл бұрын
Let me know if I can clear anything up 👍
@diliupg
2 жыл бұрын
Dope!
EDIT: Fixed it I'm having an issue with my root motion animations having their root bone blown out of proportion up into the sky when I change the animator hierarchy from "Player>rigPrefab>mesh, armature" into "Player>mesh,armature,gunRig". I'm using a humanoid rig and everything else seems to be going swell except for the root bone. FIX: Turns out my rig had some weird hidden root offset to it. I have no idea why or how but went into blender, changed "Apply scalings" in the Transform tab into "FBX units scale", switched "Armature FBX node type" from Null to Root (dunno if this matters). Then I exported it and re-imported into unity, made a new avatar based on it and had the rest of the animations take its avatar. Some say it's because some bones have a not 1-1-1 scale to them but for me all were correctly scaled.
@samyam
2 жыл бұрын
Glad you were able to figure it out!!
when i press rstore render pose my skeleton rig rotate on x axis 90 Degrees whats wrong?
how does it work ? the animator is on Parent object and the child object i.e the actual model is being animated ! Howw ??! Plss Explain. Thank You
how would i add a sprint function with animation?
Damn, I'm stuck on the exact same issue... I need my second animation layer to override the base layer, but I also wanted animation rigging to work after that. Your tutorial is the only one that I've been able to find that addresses this combination at all. If I figure out how to get this working I'll report back
@samyam
2 жыл бұрын
Thanks!! I spent hours trying to figure it out, let me know if you find out :)
@harrison298
2 жыл бұрын
Well, I spoke too soon. After briefly working fine, the animator started throwing tons of warnings. The character in my game is a dwarf, so instead of remodeling it in Blender, I was using a human model that is scaled down on the y axis, and up on the x and z. But apparently it's a known limitation with the Animation Rigging package that it just doesn't work with scaled models.
Sou fã do seu trabalho, escrevi em português só pra ver se teria curiosidade bastante para traduzir hehehe
I am making a soccer penalty kick game. the goal keeper needs to move at the direction of the ball(target). is that possible with ik constraints? the movement will look bad I guess, but it will move.
@samyam
Жыл бұрын
Movement as in position or changing the direction the body is facing? You don’t need rigging for the former, for the latter you can use the animation rigging package to rotate specific body parts in the direction of the ball
When I walk backwards my camera is to slow and can’t catch up, you end up only seeing the gun in the models hands until, when you stop moving the camera catches up.
@samyam
2 жыл бұрын
Maybe your damping is set too high in the cinemachine camera settings, try adjusting the settings/values to see what works best for you
Setting up the blend tree doesn't work for me. I hit play and the player model stays in the idle pose even when I move them around. I get an error saying "Parameter 'Hash 0' does not exist". And some of my motions in the blend tree are disconnected on play too :/ What am I doing wrong?
@samyam
2 жыл бұрын
Make sure the animation parameter and the string you are using in the code match exactly, with caps any everything. If not it won't be able to find it (in the Animator.StringToHash function)
48:32 AdBlock might be the reason why the gif wasn't working, it worked when I paused it. Sometimes admins can make such surprises. I'm sorry for my bad english.
@samyam
2 жыл бұрын
That's a good point, thank you and no need to apologize :)
When trying to create recoil for the gun, the position is not being recorded in my animation clip. Getting a yellow warning, any ideas?
@samyam
2 жыл бұрын
What does the warning say?
Is it possible to have two inspector tab?. I want inspector tab for heirarchy and 1 for project tab.
@samyam
Жыл бұрын
Right click on object in hierarchy, and select Properties at bottom
Hmm. I'm having so much issues using Animation rigging. My character's chest is backwards after my attempts. :/
@samyam
2 жыл бұрын
Backup the project, and try rigging again from scratch, sometimes that helps
How could I execute 5 animations in a row, and that each animation respects the execution time of the previous one before activating and then going back to IDLE
@samyam
2 жыл бұрын
I would use a couroutine and do WaitUntil the animation has finished playing forum.unity.com/threads/how-to-check-if-animator-animations-has-finished.1100560/ Something like this: ... animator.GetCurrentAnimatorStateInfo (0); NTime = animStateInfo.normalizedTime; yield return new WaitUntil(() => NTime > 1.0f)) ...
Having an issue where my MoveX parameter isn't updating when I move left or right, so the animation looks kinda funky :/
@samyam
2 жыл бұрын
Make sure the string matches exactly the parameter name in the animator, is the MoveZ working?
@rahaldesilva1720
2 жыл бұрын
@@samyam Did some digging, all I needed to do was restart Unity lol. But then came the next problem which was the camera stutter when trying to switch CM cams while moving. But thanks for the video! Really helpful!!
Is it possible to change de third person view for a first person view?
@samyam
2 жыл бұрын
Yeah you can switch between different cinemachine cameras, here’s the video on how to do that: How to Blend/Switch Between Cinemachine Cameras - Unity Tutorial kzread.info/dash/bejne/hJ1ssqebdJfdaKQ.html
@DarkShadowsOficial
2 жыл бұрын
@@samyam Is it possible to make a video explaining how to make a fps controller with a fullbody 3d model ?
I dot know why but my player movement isnt working properly, when i move the character faces the direction of the key im pressing instead of strafing and facing the same direction every time, this also creates issues when making animations.
@michaelechim2148
2 жыл бұрын
Hi! Did you fix the issue? I have the same problem
@hasmanking
2 жыл бұрын
@@michaelechim2148 the issue is I was using a different skeleton so I went back to mixamo and got one from there because I initially downloaded from a different site but that still isn’t an issue u would just need to adjust the grips in a different way if that makes sens, it was annoying in my opinion because I liked the skin I had before but it needed a lot of work moving around the grips to get it to face correctly, also I put the weapon under spine 1 that worked well but I want to try placing it in the hand and seeing if that gives a better effect
@michaelechim2148
2 жыл бұрын
@@hasmanking i am using a model from mixamo but my character is turning anyway
@michaelechim2148
2 жыл бұрын
@@hasmanking I fixed it! It was a problem from the previous tutorial. There was a piece of code in the original Player Controller Script that rotated the player, I just deleted it and my character strafes! Just delete this: if (move != Vector3.zero) { gameObject.transform.forward = move; }
how would i add a melee attack animation
@samyam
2 жыл бұрын
You can make it a trigger and when you press a button, set that trigger in the animator so it performs a melee animation, and at the same time check if there is an enemy in front of the player that would get hit by the animation (oncollisionenter, raycast, ontrigger enter) multiple ways to do it kzread.info/dash/bejne/lGih0dSuk5zLmaw.html kzread.info/dash/bejne/lauautOSYc7HqLQ.html
I can`t see what you are doing from 37:00 on. It`s all blurred and I can`t follow any more, when it comes to unparenting things because of the error. :(
@samyam
2 жыл бұрын
Hm that’s strange, try changing the quality settings in the video to maximum or try a different browser. It’s most likely a youtube or internet issue since the video is rendered at 1440p.
@juliaalder2007
2 жыл бұрын
@@samyam Thanks for the quick help. The problems were the quality settings. :)
this doesn't work at all for me, as soon as I add any layers it just breaks the entire rig.
gj
thanks can you add mobile control please !!! ❤❤
@samyam
2 жыл бұрын
I have a few videos on input system touch that may be useful to you :) kzread.info/head/PLKUARkaoYQT1Xwd9Az_cx-YbdvdUDNN5I
Anyone here have issues with the strafe animations playing eventhough you're not moving the player? (i.e., not pressing WASD) EDIT: I added a conditional to the strafe animations. If anyone has trouble like me here's what worked well. if (input.x != 0 || input.y != 0) { animator.SetFloat(moveXId, currentAnimationBlendVector.x); animator.SetFloat(moveZId, currentAnimationBlendVector.y); } else { animator.SetFloat(moveXId, 0); animator.SetFloat(moveZId, 0); }
thanks @samyam
can you explain animation rigging in a separate video please
@samyam
2 жыл бұрын
I have it on my list, have lots of stuff on my list! Hopefully I’ll get to it soon. 👍
@akshhhatislive
2 жыл бұрын
Ok thank-you so much
Bookmark - 46:47
@samyam
2 жыл бұрын
💯💯
@SamuelArmer
2 жыл бұрын
@@samyam yo, I asked for help on your 1st part but I’ll ask here. My camera doesn’t collide with the Enviroment layer but I have the cinemachine collider set to it Also I put a rigidbody on the floor for the gbullet decals to spawn but it makes me fall through it.
@samyam
2 жыл бұрын
Did you freeze the position and rotation of the floor? And make sure the collider is not isTrigger. For the camera make sure you put the layer on the environment object and in the cinemachine collider put that tag on to the collide against parameter. And try messing with the values (distance, radius, behavior) to see if that helps.
@SamuelArmer
2 жыл бұрын
@@samyam I did freeze the rotation and position and is trigger is turned off, as I said the player Is falling through the floor, not the floor is falling. But this time when I added the rigid body it came up with an error “non-convex mesh collider with non-kinematic rigid body is no longer supported with Unity5” so I made the mesh collider a convex and turned off is trigger but the player walks off the ground and in the sky. I then tried to make the rigidbody kinematic and it works but the decal doesn’t show. As for the camera, turned out my dumbass turned off the collider and just had to turn it back on
You remember me new brackeys ohh srry new samyam
@Rohityadav-lf4lo
2 жыл бұрын
Needed this video though
damn thats first time i see girl use unity 😂😂