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

Поделиться
HTML-код
  • Опубликовано: 19 дек 2024

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

  • @AetherXIV
    @AetherXIV 4 года назад +83

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

  • @mikedavies4237
    @mikedavies4237 Год назад +16

    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 9 месяцев назад +1

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

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

      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..

    • @mohmmadatalla4664
      @mohmmadatalla4664 3 месяца назад

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

      @@mohmmadatalla4664 Dude you saved me, the input was setting the bool to true and this was the only way I found to set it to false, luv ya appreciate ya

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

      Thank you so much for saving my 30 minutes! 🤝

  • @Hakohn2511
    @Hakohn2511 3 года назад +74

    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 3 года назад

      I was thinking the same thing!!

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

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

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

      He's not Scandinavian, no sale!😂

  • @colorzFX
    @colorzFX 3 года назад +20

    Timestamps AND actual explanations?
    Thank god I found your channel

  • @StevenBloomfield
    @StevenBloomfield 4 года назад +26

    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.

  • @sam-2796
    @sam-2796 2 года назад +15

    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 9 месяцев назад

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

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

    I have been trying to do some animations on a basic character for a week now. Finally, everything was resolved by this video. Thanks for the help

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

    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.

  • @AlexBlackfrost
    @AlexBlackfrost 2 года назад +6

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

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

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

  • @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!

  • @Khomeini_N.S.E
    @Khomeini_N.S.E 4 года назад +6

    You've done it again MR. Nicky

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

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

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

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

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

    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

  • @ninjaser6449
    @ninjaser6449 4 года назад +4

    Everytime I looking for something he always does it thank you

  • @CymbalMonkey
    @CymbalMonkey 3 года назад +4

    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!

  • @Chickengbs
    @Chickengbs 4 года назад +4

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

  • @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!

  • @blend-eren9526
    @blend-eren9526 4 года назад +4

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

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

    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

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

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

  • @tayyabchadhar3876
    @tayyabchadhar3876 4 месяца назад

    man I still love your work and the dedication you put into it. it is just amazing. Thanks for sharing.

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

    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

  • @ajmckennan1663
    @ajmckennan1663 4 года назад +2

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

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

    that the best nwq input system tutorial! big thanks!

  • @denizhacoglu1680
    @denizhacoglu1680 4 года назад +2

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

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

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

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

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

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

    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

  • @synapticstudios6388
    @synapticstudios6388 4 года назад +1

    Fantastic. Great job Nicky.

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

    in unity i get an error that states (Parameter 'Hash 20590411' does not exist) how do you fix that?

  • @dreamisover9813
    @dreamisover9813 4 года назад

    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.

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

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

  • @blabli9978
    @blabli9978 4 года назад +1

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

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

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

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

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

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

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

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

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

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

      Thanks for watching JustBitsAndPieces! :D

  • @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 !

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

    Loving your content ⭐⭐⭐⭐⭐

  • @aarondavidlewis
    @aarondavidlewis 4 года назад

    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.

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

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

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

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

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

    You're tutorials are so awesum!!!

  • @alexjackson3767
    @alexjackson3767 4 года назад +1

    Awesome stuff my man :)

  • @signalised9540
    @signalised9540 4 года назад +1

    Clean and informative video, thank you+

  • @TheAguilacelestial
    @TheAguilacelestial 4 года назад

    Excellent job Nicky! Keep it up!!

  • @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!

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

    Most Underrated channel in game dev.

  • @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!!

  • @GilbertLovesCats
    @GilbertLovesCats 4 года назад +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.

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

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

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

    Amazing tutorial, keep it up the good work !

  • @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 3 года назад

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

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

    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.

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

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

  • @akashjaiswar9437
    @akashjaiswar9437 4 года назад +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.

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

    was a life-saver. Thanks a lot.

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

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

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

      Thank you! Hope the newer content helps too!

  • @tauheedgamedev2388
    @tauheedgamedev2388 4 года назад

    Nice, your animation tutorials are so useful

  • @Arab_GameDev
    @Arab_GameDev 4 года назад +1

    thank you bro keep going up

  • @Radek_M.
    @Radek_M. Год назад

    The issues:
    14:44 when you tap the joystick player X position value is increasing (player is turning right)
    16:09 again when you tap the yoystick X is increasing and also Y is decreasing (player is turning right and goes slowly under the plane).
    How to fix this?

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

    So I did this 5 times now and my character did not move from Idle. Then I checked 'on' the 2 Boolean parameters you created at 2:29, and it worked (albeit, he only walks, doesn't run), yet your character moved, walks, then runs, then walks, then runs.... How is that possible?

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

    thank you man,you are a legend

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

    You explained it very well.

  • @blackspear7257
    @blackspear7257 4 года назад

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

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

    such a good explanation.

  • @JamesLee-lf4fr
    @JamesLee-lf4fr 3 года назад

    very good and quality materials, thanks.

  • @RehtseStudio
    @RehtseStudio 4 года назад

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

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

    This was an amazing tutorial

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

    2:30 this the part i wash looking for but how im able to do smarting like this on the event system ?

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

    For anybody who couldn't access the CharacterControls from the input. You need to place the PlayerInput script in the same location as the script trying to access it.

  • @oddlytimbotwillison6296
    @oddlytimbotwillison6296 4 года назад

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

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

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

  • @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

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

    Anyone else has an issue where the character keeps moving if the stick is let go too fast? Like if I slowly bring to stick back to (0,0) the character stops as expectet but if I quickly pull my thumb off, the character keeps walking even if I'm not touching the stick anymore. Does somebody have an idea what could be the issue?

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

      Hey! Try adding the .cancelled callback

    • @CodeLife_12
      @CodeLife_12 2 года назад +4

      If somebody has the same problem and sees this, I found the solution!
      I added this bit of code :
      input.CharacterControls.Movement.canceled += ctx => {
      currentMovement = Vector2.zero;
      movementPressed = false;
      };
      If I understood correctly, the issue was that the "canceled" event was called before the (0,0) value was registered and so movementPressed wasn't updated. Updating it here fixes that problem.

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

    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...

  • @rehrocks
    @rehrocks 4 года назад

    Awesome video congratz

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

    Thanks for a great video. However, if I wanted to use keyboard and mouse with that setup, how would the script be different? (and input)

  • @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.

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

    Nice tutorial

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

    Love this thank you man.

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

    For anyone that experiences movementPressed returning true despite not touching the joystick. Be sure to have a separate callback input.CharacterControls.Movement.canceled+={movementPressed=false}
    I notice this bug when I flicked my joystick fast and it kept moving even though i was not moving the joystick anymore.

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

      Thanks, this helped me!

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

      Where do I insert this line to fix this big cause I am experiencing this.

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

      @@yoitsmunchies you place it on the awake method of the character control script.

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

      @@djblast101
      void Awake()
      {
      input = new PlayerInput();
      input.CharecterControls.Movement.performed += ctx => {

      currentMovement = ctx.ReadValue();
      movementPressed = currentMovement.x != 0 || currentMovement.y != 0;
      } ;
      input.CharecterControls.Run.performed += ctx => runPressed = ctx.ReadValueAsButton();
      }
      Where at? I've tried a few spots but its not working.

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

      @@yoitsmunchies you didn't add separate callback
      input.CharacterControls.Movement.canceled+={movementPressed=false}

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

    decided to try it out.

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

    What Plugins you got for vs code Im not getting something here.

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

      There’s a full setup process for VSCode! I think there are some video tutorials that will help! Check out SamYam!

  • @punjabigamers751
    @punjabigamers751 4 года назад +2

    Can you do a cinemachine tutorial ?

  • @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

  • @synapticstudios6388
    @synapticstudios6388 4 года назад +2

    Unsure if this is a bug or not, but I found that using "Value" as an Action Type with my controller causes the PlayerInput to 'stick', even when no value was actively being applied to the Control Type Vector2 of Movement. Switching to Pass-Through resolved this issue.

    • @NhanTheHo
      @NhanTheHo 4 года назад +4

      ​@@iHeartGameDev By stick, he ment the left analog stick on your controller for the input system.
      I've also encountered the same issue, since Vector is a float, it doesn't always round back to exactly 0...
      in the code you written "movementPressed = currentMovement.x != 0 || currentMovement.y != 0;"
      this causes potential issues since it specifies it to be exactly 0 but floats don't always exactly land at zero
      One way to solve this is to use Math.Round but that doesn't always work since the analog stick return to the center too fast may not always recognize the vector as (0, 0).
      Synaptic Studios suggestion fixed this issue by setting it to pass-through from the input system and it worked wonderfully!
      Your guides have also been amazing Nicky! Very detailed! Hoping to see if you can make a third person shooter in the future!

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

      Thank you for this comment! I just couldn't figure out what was causing this behaviour, didn't even know what to google - this fixed it completely (and thanks to Nhan for describing why it happens)

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

    I've a problem with the joystick..... Whenever I move a joystick (little bit) the speed of the player is slow but when I move joystick farther speed is normal...I'm using 2D rootMotion

  • @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

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

    Thank you, sir, for this excellent tutorial! Is it possible to use the new visual scripting to achieve the same result?

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

      @@iHeartGameDev Thank you for the reply! My colleagues and I are visual designers who are weak with coding, but decent with visual scripting of all sorts... Grasshopper, Houdini, etc.. it would be very helpful to see a tutorial from you on the topic.

  • @AetherXIV
    @AetherXIV 4 года назад

    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

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

    3:40 this might sound like an odd question, but how did you get this screen in the inspector? I've never seen it, and I'm searching for it for ages..

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

      @@iHeartGameDev well then I must have a problem with my import, cause the transform and rotation settings are missing :( thanks anyway !

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

      @@iHeartGameDev I did, I think. I mean it's set to humanoid in the inspector. Should it be something else?

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

    Hey ! I have an issue with the script, where unity doesn't want to compile the script with this error message :
    " error CS1061: 'PlayerInput' does not contain a definition for 'CharacterControls' and no accessible extension method 'CharacterControls' accepting a first argument of type 'PlayerInput' could be found (are you missing a using directive or an assembly reference?)"
    I have double checked every step of the video but nothing has worked for now.
    The line causing issues seems to be "
    input.CharacterControls.Movement.performed += ctx =>
    {
    currentMovement = ctx.ReadValue();
    movementPressed = currentMovement.x != 0 || currentMovement.y != 0;
    };
    "
    Any idea?
    Great work btw, I learned so much with your videos!

    • @leandrosalviamarante
      @leandrosalviamarante 5 месяцев назад

      inside the input action assets, the first thing he does in the video he names it CharacterControls, name it the same

  • @m.h.kstudio1740
    @m.h.kstudio1740 4 года назад

    finally thx god i wait this for long time

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

    It could be nice a video about changing weapon or items with the d-pad for example.

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

    great tutorial

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

    I'm setting up with WASD, I get a bug that currentMovement keep reading 1 after I releasing the W or D button.

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

      @@iHeartGameDev I don’t know why but I have to set up a canceled after my performed. I need to set the value back to vector2.Zero on canceled.

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

      go to WASD keybinding and in the interactions section select "press and release"

  • @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 ? :(