How to Animate Characters in Unity 3D | Blend Trees Explained: One Dimensional

Поделиться
HTML-код
  • Опубликовано: 26 июн 2024
  • Learn how to animate characters in Unity 3D with dynamic animations from blend trees!
    This beginner-friendly tutorial is a complete walkthrough of one dimensional blend trees and how we can use blend trees to create new animations for our characters using float parameters
    ACCESS PROJECT FILES & SUPPORT THE CHANNEL:
    💛 / iheartgamedev
    iHeartGameDev Merch:
    💛 www.iheartgamedev.com
    WANT MORE?
    Interested in learning more about animating characters in Unity? Check out my growing series of tutorials:
    ✅ • Unity's Animation System
    ✦ Like the vid? Please consider Subscribing!
    bit.ly/2YdIb6j
    ✦ Missed out on the last episode?
    • How to Move Characters...
    SOCIAL:
    ✦ Discord
    / discord
    ✦ Twitter
    / iheartgamedev
    SERIES DESCRIPTION:
    This is the fourth video in a series dedicated to understanding the fundamentals of Unity's animation system. Episode 0 was an introduction to the project and explains how to import free characters and animations from Adobe Mixamo. Episode 1 was a full break down of the Animator Component. And episode 2 explained how we can use booleans to give players control of animations! Be sure to check out the other videos in the series to continue learning!
    GEAR:
    Lumix G7 Camera: amzn.to/3Kks1gZ
    Epomaker GK68 Keyboard: amzn.to/3Ke87EB
    Samson C01U Pro Mic: amzn.to/33kDdtG
    LG 27" Monitor: amzn.to/3qAHFwS
    Lepow 15.6" Portable Monitor: amzn.to/3287OtL
    Logitech G604 Mouse: amzn.to/3A6jNV4
    Audio-Technica ATH-M50X Headphones: amzn.to/3tBaeMT
    X-Pen Artist 15.6 Pro Drawing Tablet: amzn.to/3FE5HLI
    Apple 15in MacBook Pro Laptop: amzn.to/3AbKdFc
    ►TIMESTAMPS:
    Intro - 0:00
    Catch up - 0:25
    Set up - 0:38
    First Blend Tree - 0:49
    What does a blend tree do - 1:01
    Float parameters - 1:24
    Float titled Velocity - 1:35
    First look at Blend Tree - 2:12
    Motion or Blend Tree - 2:36
    Selecting motion - 2:53
    Animation Options - 3:10
    Loop Pose Explained - 3:22
    Why use Blend Trees - 4:04
    Add run animation - 4:36
    Testing Blend Tree - 4:45
    Start Coding - 5:05
    Time.DeltaTime explained - 5:41
    Acceleration - 5:54
    Working Acceleration - 6:12
    Fixing indefinite running - 6:25
    Fixing indefinite deceleration - 6:49
    Working - 7:07
    Blend Tree settings - 7:16
    Threshold - 7:30
    Visual example threshold - 7:50
    Speed Setting - 8:49
    Mirror Setting - 9:13
    2D Blend Trees Options - 9:23
    Outro - 9:47
    Thank you for watching!
    #indiegame #gamedev #indiedev #2020

Комментарии • 346

  • @ivyzheng2047
    @ivyzheng2047 3 года назад +97

    The series so far is the most explicit Unity tutorials for me to follow along so far! You're my LIFESAVER! Thank you so much Nicky! Can't wait to see the rest of them!!!

    • @NoldoWalker
      @NoldoWalker 3 года назад +2

      Agree, best about animations what ive founded for now!

  • @kentrose2520
    @kentrose2520 2 года назад +10

    Love how you explain every field in the animations, blend trees, etc. Really helpful!

  • @digital_comrade
    @digital_comrade 3 года назад +3

    I am new to Unity and this series is amazing.
    Not only is it great for teaching the concepts of animation in unity, you also do an excellent job of teaching programming basics for those that might not have them.
    Thank you for your amazing work!

  • @gaetanolombardo6150
    @gaetanolombardo6150 10 месяцев назад

    I have never listened to a clearer and more proper explanation on mechanim than this one. At last. This is gold

  • @eliebeaino
    @eliebeaino 3 года назад +1

    only 1k subs? I randomly discovered you, your videos are so high quality and cover topics in full detail and are quite systematic. I'm familiar with most of the animation system but what make you stand out from everyone else is that you cover the little nitpick details even if you aren't using them in your guide and this is what I've been looking for awhile. I've taken multiple unity courses and you are the only one covering what needs to be covered. thank you.

  • @MarkRiverbank
    @MarkRiverbank 3 года назад +17

    These are extremely helpful for learning more complex animation. A couple code tips though, it's generally better to expose your fields in the inspector by adding the "[SerializeField]" attribute rather than making them public. And, for your input handlers, there is the class "KeyCode" with static members for all the keycodes, so you don't have to use strings (eg. KeyCode.W, KeyCode.LeftShift).

  • @ARRCWoodStudios
    @ARRCWoodStudios 3 года назад +1

    I’ve learned more about animations in three of your videos than I have since I started game dev last August. Thank you so much for making these videos!!

  • @BeatTorrent5
    @BeatTorrent5 3 года назад

    This is honestly the best series on the subject so far and you also have the best method for explaining things. And it comes from someone who watched days worth of tutorials on several platforms. Love it, I honestly hope you keep up your work.

  • @fret2fret221
    @fret2fret221 3 года назад +17

    you've gained a sub man. holy crap. im actually starting to understand code and how it works. it all looks like gibberish before this particular video. now im starting to realize what it all means in the script and how its logically written. so fascinating. thank you! I don't know if its planned in your series or not but I would love to see a video on world interaction. specifically walking toward an object and picking it up, climbing onto something, etc. thank you.

    • @GameDevNerd
      @GameDevNerd 2 года назад +1

      Code is the best part! It's just a way to tell a computer what it must do and how to follow your commands. And it's not hard at all, it just looks intimidating at first, but it's all simple, short-handed ways of expressing logical processes and the flow of control. Once you get familiar with coding and learn a language you realize you can literally make anything you want happen in a computer system. :-)

  • @slsno3333
    @slsno3333 3 года назад +1

    Hi Nicky, was frustratingly stuck for days following different tutorials then youre chanel came along.
    What a life + time saver thank you so mutch can't wait to watch the rest of the tuts!
    Awesome amount of info in short movies thanks again.

  • @GameDevNerd
    @GameDevNerd 2 года назад

    I liked and even went ahead and subscribed. I'm an old DirectX programmer and C# master who just started messing with Unity and your videos solved confusion I had about getting animations working and taught me what all the editor buttons and gizmos do. I'm doing my first Unity game prototype right now and it's getting quite sophisticated. I've done all of these things before, and used to write my own engines on top of DirectX and OpenGL, but Unity is a new tool for me. So far, thanks in part to these videos, Unity has been an absolute joy to work with. I was away from development for a few years and the industry and tech has advanced GREATLY! There's never been a more fun or interesting time to be a game developer than today in 2021!

  • @OrdinaryOcean2001
    @OrdinaryOcean2001 3 года назад

    Honestly one of the best tutorials I've ever seen. It was the perfect speed and covered just the right amount of detail. Keep up the good work!

  • @CJRH1FILMS
    @CJRH1FILMS 3 года назад +15

    I'm diggin your music choice. Somehow it keeps me even more engaged, like I'm solving a puzzle in a videogame or something

    • @kitchenspider1539
      @kitchenspider1539 3 года назад +1

      Agreed... the music really gets the noggin' joggin'. weird but true

  • @tb__66
    @tb__66 Год назад +5

    Keep up the good work. So far your videos have been the most helpful in understanding not just "do this and this will happen" but WHY it happens, which is infinitely more instructive in learning how to use Unity beyond the limited scope of a tutorial.

  • @thygrrr
    @thygrrr 3 года назад +1

    Excellently structured for intermediate and advanced unity users. Awesome tutorial!

  • @lesarch
    @lesarch 3 года назад

    These tutorials are awesome! Very clear and goes straight to the point. I look forward to your future tutorials.

  • @XadegamerOfficial
    @XadegamerOfficial 3 года назад

    Yes... Been waiting for this masterpiece 🔥. Thanks Nick

  • @leahevehumphries
    @leahevehumphries 3 года назад +6

    Thank you so much! You are a lifesaver! I have 10 hours left to finish my coursework and you're helping me SO MUCH! 😭❤️

    • @iHeartGameDev
      @iHeartGameDev  3 года назад +2

      Great to hear, Leah! Happy to help 😊

  • @Jarmister
    @Jarmister 2 года назад +1

    I'm finding your tutorials extremely useful and relaxing.

  • @charlesonis3484
    @charlesonis3484 3 года назад

    So awesome to see you keep this series going!

  • @038alpha
    @038alpha 3 года назад

    You know he's a good teacher when you manage to solve your own issues just with what he told you.
    There was somthing wrong in my blending, arround 0.5 velocity it seemed like the feet and legs were barely moving, the animation was odd. So I thought maybe one animation wants left foot forward when the otherone wants right !
    Just added 0.5 offset to running and boom, done. Only because you clearly explained what is blending and what is offset.
    Seriously, congrats, i'm exited to see other videos, i'll recommend your chanel to anyone interested in video game dev. You're the first ever content creator i'll actually click the bell for haha. Thx for your work.

  • @akashjaiswar9437
    @akashjaiswar9437 3 года назад

    I used unity animations before but this series taught me new things and helped me become better then I was ever using unity. Keep on going like this sir it really helps people like me

  • @cam4722
    @cam4722 3 года назад +2

    Great presentation quality and pacing. I look forward to seeing more!

  • @phantomprogramming
    @phantomprogramming 3 года назад

    Super high quality! I was surprised to see you only have 783 subs, you deserve more!
    Keep it up!

  • @chadzulu4328
    @chadzulu4328 3 года назад

    Best Unity series that I've watched in years (since around 2016).

  • @AphixDev
    @AphixDev 3 года назад +1

    I love how you explain everything, no matter how relevant it is for this tutorial! :D

    • @gizel4376
      @gizel4376 2 года назад

      i like it too, i hate when other tutorial show you how to do something, but they assume you don't need to know what some line do, but yes i do, i need to know what everything do in my code, otherwise, how can i play with it

  • @signalised9540
    @signalised9540 3 года назад +10

    We're going to be blessed by Nick again!

  • @nathanielscheurer1821
    @nathanielscheurer1821 3 года назад +1

    I absolutely love your videos, they are straightforward, in-depth but also simple. One thing you could improve however is to take a second or two to pause when you finish a script so the viewer can look through it.

  • @alankim254
    @alankim254 3 года назад +1

    I'm learning a lot from this video. Thank you so much! Can't wait for your next video

  • @madara_u_chiha
    @madara_u_chiha 2 месяца назад

    Omg! You are excelsior! Well done Nicky! You made my day many times with all your playlists!

  • @casparrii
    @casparrii 2 года назад

    These are GREAT tutorials! Good level of detail and brilliant explanations and examples! Thank you :)

  • @omkarpatil2094
    @omkarpatil2094 2 года назад

    Sir, I love you! Thank you for this playlist! It's my first time working with Unity animations and these videos have been a blessing.
    When I'm in a state (financially) to contribute to your patron or something similar, I'll be sure to do so!

  • @ahmetaltay1946
    @ahmetaltay1946 3 года назад

    Thanks for detailed information. I was watch a lot of videos that category but this video was the best!

  • @caaccaac8712
    @caaccaac8712 3 года назад +1

    Love the relaxing background music.

  • @clerkwestwood851
    @clerkwestwood851 3 года назад

    I have just admired how clean your code is. By the way, your montage and clear explanation are topnotch.

  • @ajmckennan1663
    @ajmckennan1663 3 года назад

    Beautifully explained as always.

  • @Aphelion78
    @Aphelion78 3 года назад

    Thank you so much for these videos. I haven't been working with Unity very long but the most difficult and frustrating things for me has always been mecanim. This is the first time that I'm finally beginning to grasp the concept and make forward progress.

  • @jccfrancis
    @jccfrancis 8 месяцев назад

    Even though this is from 3 years ago, everything is so clear man, keep it up, great tutorials

  • @secrescence
    @secrescence 2 года назад

    Thanks for explaining it really well! I've been putting off learning soft soft cuz it looks so intimidating but now that I easily understood the

  • @bouchiriliass5130
    @bouchiriliass5130 3 года назад +3

    Can't wait to see you with 1M subs !

  • @saadmansuri4092
    @saadmansuri4092 3 года назад +1

    Haven't even started the video but dropped that like already cuz i know it's gonna be another mind-blowing tutorial. Ayo yo Nicky, Don't forget us OG's when you make it big on youtube xD

  • @kkrup5395
    @kkrup5395 3 года назад +1

    Wow i looked at your subscribers cound and saw 3,95 figure. I thought "nice, 4 million subs, that's why quality is so great".. And then I realized it is thousands. I feel you gonna grow rapidly, thanks for the video:)

  • @---qm3wz
    @---qm3wz 3 года назад

    you have no idea how much you've helped me, sir. please make more tutorials, we need you. --a student from from china

  • @munaokpala2998
    @munaokpala2998 3 года назад

    I really love these videos and the work ethic put into them, keep it up

  • @codeFriendlyART
    @codeFriendlyART 3 года назад

    This one felt just about right! Cool!

  • @rajasmahadule2697
    @rajasmahadule2697 2 года назад

    Thank you for making this.

  • @tinacruzart
    @tinacruzart 11 месяцев назад

    Thank you for this info!

  • @Haerinaaaaa
    @Haerinaaaaa 3 года назад

    Thank you Nick. This is awesome

  • @lenarvalolampape1813
    @lenarvalolampape1813 6 месяцев назад +1

    top tutorial series !! ty so much

  • @Asimaro
    @Asimaro 2 месяца назад +1

    im gonna say real thank to all your work man

    • @iHeartGameDev
      @iHeartGameDev  2 месяца назад

      Thank you for your kindness! I'm happy to help!

  • @alexjackson3767
    @alexjackson3767 3 года назад

    Awesome stuff as always :) !

  • @rikrishshrestha5421
    @rikrishshrestha5421 3 года назад +2

    I feel this channel has the potential to make it big.

  • @marcelorochacomposer
    @marcelorochacomposer Год назад

    Thank you! Help me a lot!

  • @cello91
    @cello91 3 года назад

    Just found your channel yesterday! Awesome content - love how accurately you explain every detail! :)

    • @cello91
      @cello91 3 года назад

      @@iHeartGameDev amazing that you just started 8 Month agieren and already put out such high quality content! Did you teach yourself?

    • @cello91
      @cello91 3 года назад

      @@iHeartGameDev Amazing! Wish you the best for Your Channel! Will join discord later today!

  •  3 года назад

    Finally. I cannot wait until the next video.

  • @chief_rasko
    @chief_rasko 3 года назад +32

    Nicky, while following the tutorial I found that when setting up the initial transition back from the first Blend Tree to the Idle animation, setting the Condition for the transition as Velocity < 0.05 caused the Animation to jitter/revert back to the Idle animation for a second before continuing with the walking -> running animations, this was quite confusing however setting the Condition for the transition to Velocity < 0.01 instead fixed the issue. Hope this helps anyone who came across the same issue

    • @RaulCesarAdolfo
      @RaulCesarAdolfo 2 года назад +2

      This helped me, thank you :)

    • @KnightFury9900
      @KnightFury9900 2 года назад +2

      OMG that bugged me out thanks mate appreciate it

    • @chananimation9484
      @chananimation9484 2 года назад +2

      You save my life mare

    • @Cap0verkil
      @Cap0verkil Год назад

      Hi can you help me with this? I don’t understand how to change the condition for to transition to velocity

    • @DeadHandRed
      @DeadHandRed 7 месяцев назад

      thanks chief

  • @samyam
    @samyam 3 года назад

    Great video Nicky!

  • @santiagorodriguezsaura9418
    @santiagorodriguezsaura9418 3 года назад

    you explain very well, great tutorial!

  • @axon266
    @axon266 14 дней назад +1

    Learning A LOT from your videos!! Thanks!!!

    • @iHeartGameDev
      @iHeartGameDev  14 дней назад

      Thank you for watching! Hope you enjoy my other content!

  • @brandonhooper7503
    @brandonhooper7503 Год назад +1

    i just had to take a minute out of banging my head against the keybord to say thank you for teaching the public. youre great!

  • @jas2890
    @jas2890 3 года назад +21

    for thos who want to still use the run with shift feature still ive pulled some messy code up for you:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class AnimationStateController : MonoBehaviour
    {
    Animator animator;
    float velocity = .0f;
    public float acceleration = .4f;
    public float deceleration = .8f;
    int velocityHash;
    public float MaxWalkingSpeed = .5f;
    void Start()
    {
    animator = GetComponent();
    velocityHash = Animator.StringToHash("Velocity");
    }
    void Update()
    {
    bool forwardPressed = Input.GetKey("w");
    bool runPressed = Input.GetKey("left shift");
    if (forwardPressed && velocity < MaxWalkingSpeed){
    velocity += Time.deltaTime * acceleration;
    }if (runPressed && forwardPressed && velocity < 1.0f){
    velocity += Time.deltaTime * acceleration;
    }
    if (!forwardPressed && velocity > .0f){
    velocity -= Time.deltaTime * deceleration;
    }if ((!forwardPressed || !runPressed) && velocity > MaxWalkingSpeed){
    velocity -= Time.deltaTime * deceleration;
    }
    if (!forwardPressed && velocity < .0f){velocity = .0f;}
    animator.SetFloat(velocityHash, velocity);
    }
    }
    ps. the variables are changed to suit my game.

    • @blaccy5991
      @blaccy5991 3 года назад +6

      Don't put every line of code into update. Put them into their own separate functions and call them.
      Also you are creating new bools every frame instead of holding them as a private variable.
      A better way would be to make a function to get inputs (isCrouching, isSprinting, isWalking etc) another function for setting your velocity velocity and a third function for setting your animator variables.
      If you do this it would be more modular, more performant and much easier to manage.

    • @jas2890
      @jas2890 3 года назад

      Blaccy thanks

    • @blaccy5991
      @blaccy5991 3 года назад

      @@jas2890 No problem. If you want I can rewrite your code

    • @jas2890
      @jas2890 3 года назад

      Blaccy no don’t worry about it it’ll keep me occupied for a little bit

    • @blaccy5991
      @blaccy5991 3 года назад

      @@jas2890 Just ask if you have a problem then

  • @signalised9540
    @signalised9540 3 года назад

    This is a great vid, ty for ur time and effort

  • @Chapter9
    @Chapter9 Год назад

    great effort dear NickyB. no one on youtube with such detail.

  • @SuperLordee
    @SuperLordee 8 месяцев назад +1

    insanely helpful tutorial. Very well explained!

  • @WanderyenErin
    @WanderyenErin 2 года назад

    You are an excellent teacher. Thank you for the video!

  • @Damian_h
    @Damian_h Год назад

    dang ur clean bro!!! thanks.

  • @jdiosilvaf
    @jdiosilvaf 3 года назад

    Amazing!

  • @paulthompson52
    @paulthompson52 11 месяцев назад

    Loved the very informative tutorial!! Would really like to see what you do with nested blend trees and how they can be used!

  • @edsarenas6389
    @edsarenas6389 3 года назад

    this is super awesome. hope you cover IK and animation layers too

  • @shsstudios5292
    @shsstudios5292 Год назад

    Excellent!

  • @DanPos
    @DanPos 3 года назад +1

    Great tutorials Nicky!

  • @27chcraft_dev80
    @27chcraft_dev80 3 года назад

    Thanks! Exaxtly what I need for my game

  • @isirapramodith8720
    @isirapramodith8720 2 года назад +1

    good tutorial . thanks

  • @diliupg
    @diliupg 3 года назад

    Excellent tutorials!

  • @AndersonMarquesss
    @AndersonMarquesss 2 года назад

    Your content is amazing!!! Thanks for share it with us.

  • @ty-xq7bl
    @ty-xq7bl 3 года назад

    best tutorials ever.

  • @AWanderingOrc
    @AWanderingOrc 3 года назад +1

    Thank you so much for posting this, I learned a lot from this vid. :)

  • @EnigmaStudioPro
    @EnigmaStudioPro 3 года назад

    Hey!
    Thanks Nicky you are an amazing Teacher. You explain everything. Please make more videos. We love you. I love your way of teaching. You explain everything.

    • @EnigmaStudioPro
      @EnigmaStudioPro 3 года назад

      @@iHeartGameDev please make more videos. We love your teaching style and editing. Thank you so much!!!
      Soon you'll hit million subscribers.

  • @PauloSamurai
    @PauloSamurai 3 года назад

    Really awesome content! thanks!

  • @evilplantosavetheworld
    @evilplantosavetheworld 3 года назад

    First off this series is friggin awesome, honestly the best unity animation tutorials I've ever found. Second off, is there a reason we don't just use Mathf.Clamp on velocity? Or is it just to avoid going into additional code?

  • @SassyPantsy
    @SassyPantsy 3 года назад +1

    Amazing tutorials man, Subbed!
    For anybody having trouble with jittering in the animation - basically a split second transition between the blend tree and back to idle, and then back to blend tree again:
    The reason this happens is that for a split second, by using an acceleration rate of 0.1f, the value of velocity is both less then 0.5f AND greater than 0, so the animation does this double transition. To fix this, Up your acceleration values to something greater (for me it's 0.5). It might be effective to do a much smaller number, but I couldn't find one.

    • @nikesh_niki
      @nikesh_niki 11 месяцев назад

      I did 0.5 but still facing the same issue. Any idea why ?

  • @kimsouza259
    @kimsouza259 3 года назад

    great content!

  • @Only4GamersXyz
    @Only4GamersXyz 3 года назад +1

    Great Tutorials 👍. Very few RUclipsrs are good as you. Seeing next Brackey in you. Just keep going like this. 🙂

  • @sudhanshusingh564
    @sudhanshusingh564 3 года назад

    Good work.. Subscribed.

  • @xdplai3190
    @xdplai3190 3 года назад

    Can't wait

  • @halimebeyzacicek8440
    @halimebeyzacicek8440 2 года назад

    thank you. good video.

  • @IN2MINUTES
    @IN2MINUTES 3 года назад +1

    Thank you

  • @TalhaRiaz197
    @TalhaRiaz197 2 года назад

    You are one of my Favourite RUclipsr

  • @linkous4924
    @linkous4924 3 года назад

    I really like your smile, and nice tutorials :)

  • @vieirapereira1298
    @vieirapereira1298 3 года назад

    i think this should be on unity official program, great work !

  • @rashidfarhan6223
    @rashidfarhan6223 3 года назад

    you are soo underrated my man

  • @CosmicComputer
    @CosmicComputer 3 года назад

    oh heck yes, blend trees have always been a source of contention for me (well, Unity's animation system in general I'd say), say Nick, do you plan to go over the new Animation Rigging package at some point? That would be a great help! Thanks for the videos, keep rocking my friend!

  • @MrBolska
    @MrBolska 3 года назад

    Awesome video

  • @shaikhabdulbasit5717
    @shaikhabdulbasit5717 2 года назад +1

    5:44 to 6:49 by all due means sir, u helped me big time, I can create my fan with this.😭

  • @buysmartter
    @buysmartter Год назад

    Dude, you are awesome! your videos are super clear, explained in details, and are really fun to watch. You are clearly investing a lot of effort doing them. Thanks! BTW, if you get to one of the videos by search (and not via the Unity's Animatin System series) it's not clear which is the next video to watch. I struggled to find the next video in the series. It would help if you put a link to next video on the description, and put at the end of each video a clearer thumbnail of the next one (Saying "part 5"...)

    • @buysmartter
      @buysmartter Год назад

      Actually you did put a link to the series in the description 🙂 so scratch that...

  • @arvinrohani3225
    @arvinrohani3225 2 года назад

    such great videos for people like me wanna give a great animation to their video game

  • @monkeyrobotsinc.9875
    @monkeyrobotsinc.9875 3 года назад +1

    i like your velocity increase decease code.

  • @zaurkurbanismailov9104
    @zaurkurbanismailov9104 2 года назад

    YOU ARE THE BEST

  • @yoannriviere5339
    @yoannriviere5339 Год назад +1

    Nice tutorial

  • @valuee5298
    @valuee5298 Год назад +1

    U r awesome! thx bro