Character Movement in Unity 3D | New Input System + Root Motion Explained

Поділитися
Вставка
  • Опубліковано 30 лип 2024
  • Learn to move characters in Unity 3D with this beginner-friendly explanation of Unity's new input system and root motion!
    With this deep dive tutorial, you will not only have a better understanding of root motion and Unity's new input system, but you will also have an animated character by the end of the video!
    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
    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
    Download From Mixamo: 0:39
    Unity Setup: 0:58
    Character Setup: 1:20
    Create Animator Controller: 1:55
    Animations To Animator: 2:08
    Animation Transition Setup: 2:30
    ROOT MOTION EXPLAINED: 3:11
    Modifying Root Motion: 3:32
    Bake Into Pose Setting: 3:49
    Based Upon Settings: 4:05
    Fixing Our Animation Issue: 4:30
    New Input System Package Install: 4:50
    NEW INPUT SYSTEM EXPLAINED: 5:08
    Interface Breakdown: 5:28
    Creating Actions: 5:48
    Action Properties Explained: 6:30
    Disambiguation Explained: 6:57
    Bindings Setup: 7:23
    Controller Detection: 7:57
    Gamepad Binding: 8:15
    Stick Deadzone Processor: 8:28
    Run Action: 8:41
    Create Player Input Class: 9:00
    LETS CODE: 9:22
    Animator Variable Declaration: 9:32
    Movement Logic: 10:00
    NEW INPUT SYSTEM CODE: 10:15
    Actions Maps & Actions: 11:00
    Event Listeners Explained: 11:16
    Callback Implementation: 11:50
    Accessing Gamepad Data: 12:29
    Enable & Disable Action Maps: 12:48
    Storing Gamepad Data: 13:15
    Moving Character Implementation: 14:00
    Character Moving: 14:43
    Rotating Character Implementation: 15:04
    Final Product: 16:09
    Next Video: 16:18

КОМЕНТАРІ • 341

  • @AetherXIV
    @AetherXIV 3 роки тому +80

    wow that was one of the best tutorials I've seen. you show us everything AND most importantly -explain why. Thank you very much

  • @Hakohn2511
    @Hakohn2511 3 роки тому +69

    Brackeys is gone, but seems like we have a new one here that may be taking his crown :D

    • @remcrap1139
      @remcrap1139 3 роки тому

      He has potential

    • @devinmcgee5265
      @devinmcgee5265 2 роки тому

      I was thinking the same thing!!

    • @lqd8367
      @lqd8367 2 роки тому +1

      Brackeys helped us in though time ......

    • @Ihasfinger911
      @Ihasfinger911 Рік тому

      He's not Scandinavian, no sale!😂

  • @StevenBloomfield
    @StevenBloomfield 3 роки тому +25

    I like how you bring focus to the proper section of the UI by either zooming and blurring background or using the red arrows. Also nice to see a reminder of what was entered in the UI while going over the script.

  • @RussmanDesignHD
    @RussmanDesignHD 3 роки тому +14

    This is one of the best tutorials on Input I've seen in a long time! Very understanding in explanations. I hope you do much more in the future.

  • @CymbalMonkey
    @CymbalMonkey 2 роки тому +3

    Found this by chance but you explained this really well, making it far more understandable than others I have watched. Giving the info really is key for any viewers to learn so this was perfect. Good job, subbed for future stuff!

  • @colorzFX
    @colorzFX 3 роки тому +18

    Timestamps AND actual explanations?
    Thank god I found your channel

  • @blend-eren9526
    @blend-eren9526 3 роки тому +4

    I've been waiting for this video for so long, thank you!

  • @charuzu1397
    @charuzu1397 2 роки тому +1

    Been binging your vids all day to get a better understanding of movement controllers in unity, i love your vids man, thanks for being awesome!

  • @Chickengbs
    @Chickengbs 3 роки тому +4

    Nicky my man, We love youuuuuuuuuu!! We're so greatful for all the work and effort. Please give up more! :D

  • @Tiger66261
    @Tiger66261 3 роки тому +1

    Absolutely brilliant tutorial. Your combination of clear instructions and great video editing is the perfect combination.

  • @Cerealfrog
    @Cerealfrog 3 роки тому +1

    So glad I took a chance watching this. It's criminal that you don't have a bigger following, this was a very well made instructional!

  • @ajmckennan1663
    @ajmckennan1663 3 роки тому +2

    It’s here! Woohoo!!! Amazing stuff as always!

  • @aarondavidlewis
    @aarondavidlewis 3 роки тому

    After a series of really great videos, I'm now watching every video you post... which I do with only about 20 creators out of the hundreds of great youtubers on my shortlists. Keep up the great work.

  • @dreamisover9813
    @dreamisover9813 3 роки тому

    Thanks! Very good and digestive tutorial. Sometimes when I watch tutorials, it feels like I need some discipline to keep watching, but for this, time passed in an instant, it flew so well.

  • @ninjaser6449
    @ninjaser6449 3 роки тому +4

    Everytime I looking for something he always does it thank you

  • @AlexBlackfrost
    @AlexBlackfrost Рік тому +4

    Almost 2 years later I still come back to the root motion section. It's explained way better than in the docs.

  • @abhinavsatheesh9640
    @abhinavsatheesh9640 2 роки тому

    dude your great .I watched your video when ever i have doubt in player animation, you really deserve a medal .Thank you once again

  • @denizhacoglu1680
    @denizhacoglu1680 3 роки тому +2

    I'm glad you are back! Keep continue brother.

  • @LaurentBRISSON
    @LaurentBRISSON 3 роки тому

    You are great! I've been looking for an explanation of the new input system for a long time and you explain things really well, in a clear and simple way! Thank you!

  • @Jet_Mishemoto
    @Jet_Mishemoto 3 роки тому

    Dude your tutorials are a saving grace please continue the work you’re doing

  • @GilbertGames
    @GilbertGames 3 роки тому +4

    Probably another really great tutorial I'll have to learn later today. Hope your Channel grows big, you put so much effort into it, and they come out as the best tutorials I've seen.

  • @sonisinha8912
    @sonisinha8912 3 роки тому +3

    The best tutorial for learning animation character controlling.U are the best Sir!

  • @ignacio3602
    @ignacio3602 Рік тому

    you're a great teacher, love the simplicity, with details! subbed!

  • @toyfox4228
    @toyfox4228 Рік тому

    TNice tutorials is by far, the best tutorial I have found so far. I feel like I’ll be spending a lot of ti on your channel! Thanks man! Keep up the good

  • @missmealey
    @missmealey 3 роки тому

    Really useful video, super easy to follow and everything was explained so well! Thanks

  • @sam-2796
    @sam-2796 2 роки тому +12

    Thank you for well explained tutorials, you have helped me a lot keep going man, i just want to mention 7:23 guys make sure that you choose pass through ( Action Type ) otherwise the player will keep moving in the idle state i've discovered this problem after 9 hours of digging Lol small advice make sure you have a cup of coffee to avoid these types of mistake xD, Again Thank you so much !!

    • @blackulrich
      @blackulrich 2 роки тому

      Thank you very much!

    • @juansotomayor9076
      @juansotomayor9076 4 місяці тому

      Damn, you saved me a lot of frustration!. Any reason why that happens?

  • @synapticstudios6388
    @synapticstudios6388 3 роки тому +1

    Fantastic. Great job Nicky.

  • @TheAguilacelestial
    @TheAguilacelestial 3 роки тому

    Excellent job Nicky! Keep it up!!

  • @AlexBlackfrost
    @AlexBlackfrost 3 роки тому

    Great video, Nicky! Very professional

  • @cookiewood6727
    @cookiewood6727 2 роки тому

    Amazing tutorial, keep it up the good work !

  • @tauheedgamedev2388
    @tauheedgamedev2388 3 роки тому

    Nice, your animation tutorials are so useful

  • @alexjackson3767
    @alexjackson3767 3 роки тому +1

    Awesome stuff my man :)

  • @signalised9540
    @signalised9540 3 роки тому +1

    Clean and informative video, thank you+

  • @Khomeini_N.S.E
    @Khomeini_N.S.E 3 роки тому +6

    You've done it again MR. Nicky

  • @qwerty6vov
    @qwerty6vov 3 роки тому +1

    that the best nwq input system tutorial! big thanks!

  • @chupirupee
    @chupirupee 2 роки тому

    You're tutorials are so awesum!!!

  • @AspiringHeroGames
    @AspiringHeroGames 3 роки тому +1

    Thank you so much for creating this tutorial!
    It's been a great help for transitioning to the new Input System from the old one!
    Subscribed!

    • @iHeartGameDev
      @iHeartGameDev  3 роки тому +1

      Thank you for watching Aspiring Hero Games! Good luck with your dev journey

    • @yokj9081
      @yokj9081 2 роки тому

      @@iHeartGameDev excuse me I have some unity question. somebody can help me?I am Taiwanese so my English is not well.

  • @oddlytimbotwillison6296
    @oddlytimbotwillison6296 3 роки тому

    Nicely done! I've been very eager for a new input system, the old one was so bad for local co-op games.

  • @blackspear7257
    @blackspear7257 3 роки тому

    Great video!! Eager for the video on Animation Rigging package! 😄

  • @RehtseStudio
    @RehtseStudio 3 роки тому

    I like to see how other use the new Input System, well done Nicky👍.

  • @moniques1377
    @moniques1377 2 роки тому +1

    Loving your content ⭐⭐⭐⭐⭐

  • @blabli9978
    @blabli9978 3 роки тому +1

    hes just like us he didnt know about this, but he learned it and shared it to us. Thanks a lot!

  • @ambiguouscompany
    @ambiguouscompany Рік тому

    Man OG OG I been messing with that Unity input system and no one out here explaining the callback f(x) like you. I been watching all these weird writing event function stuff and it make no sense to me. Been just reference my control scheme states instead of that performed function...still work, now I can pull out them more complex parameters like duration of that button press...
    Love your tutorials mane

  • @IamMegaJustMega
    @IamMegaJustMega Рік тому

    This is an amazing video to learn the new input system.

  • @galogalliani1746
    @galogalliani1746 2 роки тому +1

    TNice tutorials tutorial is so useful,I tried tons of other tutorials but tNice tutorials was the best one

  • @mominafaraz9924
    @mominafaraz9924 Рік тому

    was a life-saver. Thanks a lot.

  • @m0ch1_6
    @m0ch1_6 3 роки тому +1

    Underrated tutorial... You deserve Million sub's.. Great vid

  • @akashjaiswar9437
    @akashjaiswar9437 3 роки тому +1

    Awesome job to you Unicky (Bad pun😅)(Replying to your awesome job to us in the ending). Understood root motion and the new Input system. Excited for the next videos in the series.

  • @changtc8873
    @changtc8873 3 роки тому

    Love this thank you man.

  • @bbtoon
    @bbtoon Рік тому

    thank you man,you are a legend

  • @wesley6442
    @wesley6442 6 місяців тому

    Thank you so much for this informative series, I am terrible with code but am forcing myself to go through the steps and follow along, its really what drives the game so I have to learn some of it haha, for a good while I was fighting with the code and using copilot and chatgpt to figure out why my character kept moving despite letting go of the thumb stick and I figured out it was my controllers sensitivity, it would be above a certain threshold even if I thought it was centered, its not a really old controller but the inputs are apparently a little sensitive

  • @Arab_GameDev
    @Arab_GameDev 3 роки тому +1

    thank you bro keep going up

  • @mikedavies4237
    @mikedavies4237 7 місяців тому +4

    At 13:58 you should add another handler:
    input.CharacterControls.Movement.canceled += ctx => movementPressed = false;
    If you don't do this then movement will not cancel if the user doesn't guide the stick back into the deadzone (they just release it so it snaps backs to centre). Will save someone 30 minutes trying to find where the bug is.

    • @drmeatball124
      @drmeatball124 4 місяці тому +1

      Had this issue, thought it was my controller failing.. ty!

    • @Hoptronics
      @Hoptronics 2 місяці тому

      This comment is Golden when using the keyboard.. I had to put it on everything, aim, shoot, jump I'm still figuring out how I can get what I need outta the input system but.. yeah I'm closer now.. thanks again..

  • @JamesLee-lf4fr
    @JamesLee-lf4fr 3 роки тому

    very good and quality materials, thanks.

  • @kevinsetiono9933
    @kevinsetiono9933 3 роки тому

    You explained it very well.

  • @siba2893
    @siba2893 3 роки тому

    This was an amazing tutorial

  • @itadori6807
    @itadori6807 Рік тому +1

    fav and tysvm for this tutorial it was helpful❤️.

    • @iHeartGameDev
      @iHeartGameDev  Рік тому

      Thank you! Hope the newer content helps too!

  • @TrippyGamer
    @TrippyGamer 3 роки тому

    This is THE BEST tutorial!!! on the new input system why doesn't it has more views!!?!?!!

  • @Bugzzyy
    @Bugzzyy 3 роки тому

    Dude you're AMAZING! You explain as you show how/where to find it. You show where to find it again with arrows. I could go on lol, but thanks your tutorial are what is was looking for. Thank you!!!

    • @iHeartGameDev
      @iHeartGameDev  3 роки тому

      Thanks so much Bugzzy! 😊 happy to hear that you like the videos!!

  • @juanpablocoloradotuberquia7361
    @juanpablocoloradotuberquia7361 3 роки тому

    such a good explanation.

  • @m.h.kstudio1740
    @m.h.kstudio1740 3 роки тому

    finally thx god i wait this for long time

  • @agarwalpublicintercollege7890

    help to get the basics and I'll jus move from there. Thank you!

  • @catastic9394
    @catastic9394 4 місяці тому +1

    Thank you

  • @JustBitsAndPieces
    @JustBitsAndPieces 3 роки тому +1

    wow this is so well made, more please just found the channel

    • @iHeartGameDev
      @iHeartGameDev  3 роки тому

      Thanks for watching JustBitsAndPieces! :D

  • @sammaji9475
    @sammaji9475 3 роки тому +1

    Amazing ❤❤❤

  • @rehrocks
    @rehrocks 3 роки тому

    Awesome video congratz

  • @TrueIndian
    @TrueIndian 3 роки тому

    Quality content!

  • @mowalduchiwa1560
    @mowalduchiwa1560 2 роки тому

    love this channel

  • @silvianepasquali6807
    @silvianepasquali6807 Рік тому

    Nice tutorial

  • @gamin8ing
    @gamin8ing 3 роки тому +1

    Hey Nick! I've a doubt that I'm using a 2D freeform directional blend tree and a sprinting animation transitioned to it. But when I toggle sprint I sharply switches to it, is there any way to smoothen the transition between them, or when in blender tree (2D freeform) jogging to walking to idle animation. 🙏🙏🙏 Thanks in advance...

  • @vishnudevvasudevanpillai2461

    with it in a few weeks or months if I pour enough ti and effort into it. I'll be watcNice tutorialng many more of your videos for tips and inspiration.

  • @ddinoboy
    @ddinoboy Рік тому

    lol 3:53 on pause helped me more than dozens of videos. thanks!

  • @Oleg_UE5
    @Oleg_UE5 2 роки тому

    One more great tutorial! Are you planning to make series about IK you mentioned before?

  • @eterlan2538
    @eterlan2538 3 роки тому +14

    hey! thanks for your tutorial! Really well understanding and explicitly. I want to make a few suggestions about the code.(might be wrong..)
    1. Instead of using if statement in the Update loop, I think using CharacterControls.Movement.cancelled to "SetBool = false" is better for performance.
    2. There is no need to decide whether movementPressed is true or false using currentMovement.x != 0 || currentMovement.y != 0, because when the "performed" callback is in response, the button is pressed certainly.

    • @iHeartGameDev
      @iHeartGameDev  3 роки тому +10

      Hey Eterlan! If you find more efficient ways of doing things in the code and everything works, go for the refactor! Code is always open to being optimized and refactored for the better! Love to see it, honestly. Cheers 🍻 -Nicky

  • @nikodromikro
    @nikodromikro 2 роки тому

    great tutorial

  • @donutxd3903
    @donutxd3903 Рік тому

    decided to try it out.

  • @OFCIFR
    @OFCIFR Рік тому

    I found this video to be very complicated compared with how easy you make everything to understand in other videos. Good job anyway !

  • @icarosh1
    @icarosh1 3 роки тому +2

    I don't know if someone already asked, but how do the values get reset after receiving the input? runPressed will always be true after the first input (Run.performed). Same for currentMovement values they will always be 1 as soon as you press they key. I had to use CharacterControls.Movement.canceled in order to stop the motion. Is that the way is supposed to be? My question is how do you recognize a key being held with the new input system when the values do not update every frame? Thanks for the tutorials

  • @freddycortina
    @freddycortina Рік тому +1

    I think you are the best unity helper on all universe thanks to you for helping us so much

  • @zaurkurbanismailov9104
    @zaurkurbanismailov9104 2 роки тому +1

    The best!

  • @Xind0898
    @Xind0898 3 роки тому

    This is godsend

  • @andrewwhitton1812
    @andrewwhitton1812 3 роки тому +1

    soooo... how does this work with the previous animator tutorial where we used the velocity float to blend and play the animations for walk to run?
    finding the new input system to be quite confusing

  • @gamercat7301
    @gamercat7301 Рік тому +1

    thank you so much

  • @th3R341W3n
    @th3R341W3n 2 роки тому

    Hi I want to know on 13:42, when your cursor is on ReadValueAsButton, there's API explanation appears. I want to know how do you do that in VSCode? I moved my cursor to that keyword, and hold Ctrl key, and there's only some syntax statements appear...

  • @samyam
    @samyam 3 роки тому +1

    Great video! Tons of useful information 🙂

  • @grombula721
    @grombula721 3 роки тому +1

    Great video! How would you recommend changing the charactermovement script to move the character based on the position of a cinemachine camera

  • @codeFriendlyART
    @codeFriendlyART 3 роки тому

    Plus+Ultra informative! Love your videos man. I did learned quite a lot from it, as with all of your amazing series! I totally feel the negatives are from pure envy, possibly from other content producers wanting to make the stats to look bad most likely because they are afraid of your steady progress and impressive video quality/content. After all, not many can manage to pull out such a huge amount of high quality content in barely 15 minutes... I'm confident Unity Technologies will get to note your series and approach you. Your videos are simply the best organized, well presented, clear and informative Unity videos out there I've seen so far, period. Hope you're having a nice holiday and keep up the great work man! 🔥💪

  • @NicholasScotti
    @NicholasScotti 3 роки тому

    is it possible to do a movement like a car, for example, press w, player goes from 0 to speed variable and if you release w go from speed varible to 0 ?(or for the controller stick slow movement = slow speed, full stick movement = full speed) but not via script

  • @edw1958
    @edw1958 Рік тому

    The issue would it be What version of Unity that can make icon of Input Actions in Assets of the Projects window, I tried many times that failed though I understand that I have installed the Input System Package in my Project settings, help please.

  • @JackJoeMcPherson
    @JackJoeMcPherson 3 роки тому

    Amazing work as always Nicky! How would I get this to work with a blend tree with strafing? I understand from your previous tutorials there's quite a lot more to it haha! I'd really appreciate the help! From you or anyone in this nice community!

  • @MrBobni
    @MrBobni 3 роки тому

    very nice TUT .
    the new input system is a bit overwhelming for me :/
    I need to practice a bit .
    subscribed + liked + shared the video
    thanks a lot

  • @hackerasaweshacreasedd
    @hackerasaweshacreasedd Рік тому

    You have no idea how grateful I am for tNice tutorials series

  • @AetherXIV
    @AetherXIV 3 роки тому

    Nicky B, can't wait for the rigidbody video :) my character is slowly sinking into the ground and maybe that video will help my guy get out of quicksand
    edit: seemed to have fixed it by baking the Y position into the pose

  • @macleodgordon
    @macleodgordon 3 роки тому

    So, at 8:05 where you clicked the controller, when I did that, nothing happens, I had to right-click the controller and choose 'Open Device Debug View', only then did I see the activity you show in your video when clicking various controls on the controller. Thought this might help others.

  • @AlesAlex
    @AlesAlex 3 роки тому

    Great video! Is it possible to modify the button mapping in code with the new Input system?
    I hope you talk about the famous dilemma "character controller vs rigidbody" in your next video. I have read a lot about it but I still dont know which one should I use.

  • @prathameshgaikwad7550
    @prathameshgaikwad7550 Рік тому

    well if release the button the character stops suddenly, which doesn't seem nice, do you have any idea, how we could smoothly ease in and out between the run, walk and idle.

  • @dranora9208
    @dranora9208 3 роки тому +1

    Can you explain me how we can block that the character pass through the walls when using an animation with root motion ? :(

  • @cameronkent8517
    @cameronkent8517 2 роки тому

    Maybe I missed something, I have gone through the video a couple times, but for some reason the isWalking bool is not triggered when I release the stick. Any idea how to fix?

  • @rubangakeneinnojoseph7463
    @rubangakeneinnojoseph7463 3 роки тому

    cool thanks

  • @taglewebgaming
    @taglewebgaming Рік тому

    Hi ! Very informative video! However my question is if it is possible that when the player turns, that the joystick having a different position does not make the player return in the position of the joystick but based on the current one. What is not the case in the video...