2D CHARACTER MOVEMENT IN UNITY 🎮 | Rigidbody2D Movement And Jumping In Unity | | Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ค. 2024
  • In this Unity tutorial I will teach you how to move and jump in Unity with a 2D character! 😊 This video will be a introduction to C# programming and how to move and jump using Rigidbody2D.
    Learn C# here: • 1: Introduction To C# ...
    Download Unity here: unity3d.com/get-unity/download
    ➤ TIMESTAMPS
    00:00:00 - Introduction.
    00:00:17 - Getting Unity ready!
    00:00:42 - Creating our Sprites.
    00:02:21 - Adding Rigidbody2D and Colliders.
    00:04:27 - Creating our C# PlayerController Script.
    00:05:36 - I have a C# course!
    00:06:06 - Understanding what is in our Script.
    00:06:43 - Fields, Properties, and Methods in C#.
    00:08:40 - Using, Classes and MonoBehaviour in C#.
    00:10:11 - Start(), Update(), and FixedUpdate() in C#.
    00:11:09 - The Void keyword in our methods?
    00:13:21 - Creating our Fields.
    00:16:59 - Assigning values to our Fields.
    00:19:33 - How to get player input.
    00:21:12 - Moving our player using AddForce.
    00:25:09 - Jumping using AddForce.
    00:26:05 - Checking if player is grounded.
    00:27:05 - Adding a ground check Trigger.
    00:27:58 - Preventing player rotation.
    00:28:20 - OnTriggerEnter2D() in C#.
    00:29:20 - How to add tags to game objects.
    00:30:32 - OnTriggerExit2D() in C#.
    00:31:02 - Prevent player double jumping.
    00:32:11 - Final adjustment to our Rigidbody2D.
    00:33:32 - Thanks for watching!
    ➤ GET ACCESS TO MY LESSON MATERIAL HERE!
    First of all, thank you for all the support you have given me!
    I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
    I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
    I hope you will find it helpful :)
    Patreon: / mmtuts

ความคิดเห็น • 560

  • @protophase
    @protophase 2 ปีที่แล้ว +153

    Finally someone who acknowledges the importance of why. So many videos that I have watched just instruct you WHAT to type in to the code and which checkmarks you should have but never do they tell you WHY, which makes the information totally useless because you can never use it in any other situation.

    • @alexandratrenkova9339
      @alexandratrenkova9339 ปีที่แล้ว +4

      Give a man some food,, and he'll live for a day. Teach a day how to fish, and he'll survive for years. So important!

    • @vihansgaming
      @vihansgaming 8 หลายเดือนก่อน +1

      yeah i just watch tutorial nothing what i learn from but in this video he is telling everything
      this video is awesome

    • @wingingglobe4095
      @wingingglobe4095 7 หลายเดือนก่อน +2

      This is exactly what made me give up on game development before. You can watch a tutorial and implement everything correctly but if the video doesn't explain, you still don't understand anything

  • @leet37a9
    @leet37a9 2 ปีที่แล้ว +28

    This, by far, actually taught me something. Thank you so much for making this video, Dani. At the very least, I think I've learned some core concepts of the codes you have introduced here.

  • @thissideofmyworld7216
    @thissideofmyworld7216 2 ปีที่แล้ว +3

    I am getting intetested in game dev and you are beautifully teaching me the way through it. I thank you so much, I devoured this video in the best sense of the term. It shows the crazy amount of devotion you have to teaching.
    Thank you once more.

  • @jorgesanzana4262
    @jorgesanzana4262 8 หลายเดือนก่อน +3

    best tutorial ive seen on programming for beginners!! like any new subject youre completely unfamiliar with, there's a whole universe of things you need to learn in order to make your own mental image and understanding of the topic in order to really learn stuff instead of memorizing. the way its explained on this video really helps with that

  • @AmierAzzeal
    @AmierAzzeal 9 หลายเดือนก่อน +4

    Its Great to see someone explain things and does'nt just gloss over it or assume people already know what everything means.

  • @jamesjam
    @jamesjam 2 ปีที่แล้ว +8

    This walk through is amazing so detialed but still welcoming for new game designer and programers like myself. Thanks so much!!!

  • @dazza22
    @dazza22 2 ปีที่แล้ว +3

    finally a tutorial that actually EXPLAINS why and what the code that we need to type does. I've been looking all over for this. Thanks so much!

  • @dylanc5636
    @dylanc5636 ปีที่แล้ว +22

    This is the first video of yours I've watched, and the best tutorial I've seen that (as many others have pointed out) actually explains WHY you're writing a certain line of code and how everything interacts with each other as opposed to just telling you what to write. I ended up taking notes on paper and also adding notes into the script so I can go back and remember what the fields and everything are actually doing.
    Thanks SO much for this, subscribing and probably devouring all the rest of your videos!

  • @Babtu
    @Babtu ปีที่แล้ว +2

    I just wanne say thank you for the course! You're not only explaining it flawless but you're making it fun!

  • @meliasnahtony2951
    @meliasnahtony2951 2 ปีที่แล้ว +3

    Out of every channel I've looked at, you were the most informative.
    Thank you!

  • @md.jannatulnayem4328
    @md.jannatulnayem4328 3 ปีที่แล้ว +1

    While I was doing my PHP projects I came to know this channel. I loved those videos.
    I guess I never expressed enough gratitude. Thank you!!!!!!! Well now I am all about C#....I hope we have a long journey ahead 👊

  • @average337
    @average337 2 ปีที่แล้ว +3

    Im just seeing this now after using many other vids that didn't explain as well as yours. I have decided to make a game on spring break, thanks a ton and i'm sure i'll watch more of the vids you have made to help me

  • @samkroes4611
    @samkroes4611 ปีที่แล้ว +2

    Super helpful video! I've been going through this Unity intro series and learning a ton! You are great at anticipating my questions and explaining everything. I watched your pixel art tutorial, and am excited for the C# series too. Thank you so much!! It's hard to believe resources like this are free.

    • @Dani_Krossing
      @Dani_Krossing  ปีที่แล้ว +2

      You are so welcome Sam. 🙂 I hope I continue to anticipate questions you might have.

  • @goomba8170
    @goomba8170 ปีที่แล้ว

    Thank you so much for actually explaining the code here, it’s purpose and why it’s being used in this instance. The phrase ‘give a man a fish, and he’s fed for a day, teach a man to fish, and he’s fed for a lifetime’ comes to mind. Every other tutorial has just been tossing fish, whereas this one has actually managed to teach me something effectively.

  • @himiko4202
    @himiko4202 2 ปีที่แล้ว +6

    This is one of the best videos i've seen for learning this! You really go into detail about what things mean and when you should use them. Thanks alot! I'll definitely recommend this video to anyone i know who wants to get into coding :))

    • @mcnugget4227
      @mcnugget4227 2 ปีที่แล้ว +1

      Every time I typed Rigidbody2D in my code it didn't call it, and I have no clue how to fix this. Did something change in the 2022 version or am I making a mistake? I saw your comment was from only one month ago so I was wondering if something similar happened to you.

    • @vagabxndd
      @vagabxndd 2 ปีที่แล้ว

      @@mcnugget4227 same thing here, it doesnt call the rigidbody

  • @PROFPANDA-jm7ru
    @PROFPANDA-jm7ru ปีที่แล้ว +1

    The best tuto ever, finally someone I understand and find easy to follow with! Just started out and your video really helped out so much, thank you! cheers

  • @abdallahgamer6298
    @abdallahgamer6298 10 หลายเดือนก่อน +1

    Actually this is the tutorial that I am going to stick with and ur channel is great keep going

  • @josephfrost2765
    @josephfrost2765 2 ปีที่แล้ว +2

    Even though I knew how the character movement worked this video just helped me a lot with understanding it again. Thank you

  • @almaaanea
    @almaaanea ปีที่แล้ว +6

    This is the first player movement script that REALLY worked for me, that I understood. I'm relearning Unity after I took a huge break from coding so thank you so much for helping me bounce back

  • @davidkirk831
    @davidkirk831 2 ปีที่แล้ว

    Awesome vid, filled in lots of gaps for me! Following and downloading all your stuff as well

  • @KingAbodi206
    @KingAbodi206 3 ปีที่แล้ว +5

    nice video, keep going. I really like your tutorials

  • @ricomine2pl136
    @ricomine2pl136 ปีที่แล้ว

    I had a lot of fun follwing the steps in your tutorial and everything worked. Now i can jump around with my little square. Cool!

  • @bubblegum1653
    @bubblegum1653 ปีที่แล้ว +2

    you're a life safer. Most tutorials dont explain what we're coding and when i did something wrong i wouldnt know how to fix it. But you explained very well. thx

  • @TeeGeeOfficial
    @TeeGeeOfficial 2 ปีที่แล้ว

    this is a fantastic tutorial that assumes no previous knowledge (very much appreciated) thank you!

  • @entity1325
    @entity1325 2 ปีที่แล้ว

    i've been struggling to find tutorials on unity to fit my mind and yours do a very good job of that, thanks.

  • @francoisdebruin6293
    @francoisdebruin6293 ปีที่แล้ว +1

    Na this dude is legit he makes sure to think about what would a new Dev be thinking he does not only think from an experienced point of view subbed man

  • @maka_dev
    @maka_dev ปีที่แล้ว +1

    Best guide i've watched about the topic 👍
    Im also learning c# from zero, your video helped a lot, thanks

  • @tassimo9995
    @tassimo9995 9 วันที่ผ่านมา

    I have watched so many tutorials on youtube by now and this is by far the best one! you explain things so thoughtfully and clear. keep it up, you gained a new subscriber!

  • @bluefiregamingandcards
    @bluefiregamingandcards ปีที่แล้ว +1

    A very well made video. You are truly a great teacher for this subject. Thank you.

  • @beastmasterbg
    @beastmasterbg 2 ปีที่แล้ว

    Thank you very much for the tutorial. Its easy and simple to follow !

  • @Yurem_
    @Yurem_ ปีที่แล้ว +1

    Thank you Thank you Thank you!! this is so far the most detailed tutorial I've seen

  • @zoem6195
    @zoem6195 ปีที่แล้ว +4

    I've never been so thankful in my life. I've spent over 20++HRS trying to fix my jumping mechanics going through soo many tutorials hoping it would fix my issue and THANKFULLY this has been the one and only that has fixed my issue. Thank you soooo much!!! I am subscribing and liking this video and keeping this Channel as my go to for my issues. Its so informative especially for a beginner. I can't help myself but to thank you again once more.

  • @Lyttii_
    @Lyttii_ ปีที่แล้ว

    Thanks for explaining everything so in depth!

  • @preciousessien163
    @preciousessien163 ปีที่แล้ว

    I've been looking for this for a very long time!

  • @lux_5797
    @lux_5797 ปีที่แล้ว

    This is the best Unity tutorial i ever seen , it explains everything and easy to understand

  • @stanleyhavok
    @stanleyhavok 9 หลายเดือนก่อน +1

    Thank you, for taking the time to just explain(with examples) the little things Even when you say your not going to. !

  • @Couldbeme
    @Couldbeme 2 ปีที่แล้ว

    I love how in depth you are

  • @pu55yEaterr
    @pu55yEaterr 2 ปีที่แล้ว

    This is one of the best tutorial, or more like a lessons, on Unity I've ever seen

  • @gengatuberofficial7009
    @gengatuberofficial7009 10 หลายเดือนก่อน

    Thank YOU!! I LEARNED THIS AWESOME MOVESETS!!

  • @peterkim9696
    @peterkim9696 2 ปีที่แล้ว

    Love your tutorials dani 🥰

  • @samuv8864
    @samuv8864 2 ปีที่แล้ว

    Oh my lords this was an absolute gold tutorial. (It's bit ironic that I say gold as the character for game I worked on was a golden coin.) I had some troubles first with visual studio and unity not linking well, but then i discovered that I had to use visual studio code and not visual studio it's self. After getting that done following through the tutorial was actually fun and some great time as this was my 3rd day trying to work with unity.
    Also the length didn't really matter it was great getting to know terms and usefull info about unity, as i really wanna learn to use it on my own someday.
    Thank you so much!

  • @msv266
    @msv266 2 ปีที่แล้ว

    Amazing! Things make so much more sense now

  • @mahiincheck
    @mahiincheck ปีที่แล้ว +2

    Man u really cool and the way you explained everything deserves a like

  • @learnenglishwithstories3571
    @learnenglishwithstories3571 5 หลายเดือนก่อน

    You are a lifesaver! Thanks for your videos!

  • @FisherTPS
    @FisherTPS 2 ปีที่แล้ว

    how tf do u not have more views, best tutorial on youtube. YOU NEVER LEAVE ANYTHING OUT!

  • @FondsRL
    @FondsRL ปีที่แล้ว +1

    It finally worked! After two months of watching tutorials he moves!!!!!

  • @blockybrainz4026
    @blockybrainz4026 6 หลายเดือนก่อน +1

    i can actually make my game now ty so much love your vids bro!

  • @thatguyelibeats4031
    @thatguyelibeats4031 ปีที่แล้ว +1

    SUPER HELPFUL!

  • @pumpkinpeen5937
    @pumpkinpeen5937 2 ปีที่แล้ว

    Wonderfully explained!

  • @focalgain
    @focalgain ปีที่แล้ว

    Amazing video. Followed it to the end very educational. Thank you for your time and effort you have my support

  • @ItsAkile
    @ItsAkile ปีที่แล้ว

    thank you, this should go a long way. I forgot almost everything since the last time I've dabbled, most of my Errors were a "}" placements 😅 but now it works fine, now to apply to some gameplay

  • @me3699-f7f
    @me3699-f7f ปีที่แล้ว +1

    This is really well explained

  • @archerburger143
    @archerburger143 2 ปีที่แล้ว

    Considering the amount of views on this video, it certainly doesn't have enough likes. it deserves so many more.

  • @drakebifugha7727
    @drakebifugha7727 ปีที่แล้ว

    I love the way you explain every single detail. You just got one subscriber.
    THANKS
    PLZ make more

  • @yashraj1928
    @yashraj1928 ปีที่แล้ว

    Hey! Thanks so much for this video!

  • @AhmedRamy585
    @AhmedRamy585 ปีที่แล้ว +1

    Fantastic Video

  • @sherwing9054
    @sherwing9054 3 ปีที่แล้ว

    I'm gonna come back and thank Dani fully when I sign the contract for C# dev, your videos really helped me pass the technical exams.

    • @sherwing9054
      @sherwing9054 2 ปีที่แล้ว

      I got a job as a c# dev, thanks dani, but the pay is minimum wage. Eh, still ok I guess, got some mouths to feed now.

  • @raminlamian6560
    @raminlamian6560 ปีที่แล้ว

    Nice & clear, thanks a lot 🙃

  • @ciucanluca139
    @ciucanluca139 ปีที่แล้ว

    THANKS FOR THIS IV BEEN SEARCHING FO SOOO LONG

  • @meowymeowz1604
    @meowymeowz1604 ปีที่แล้ว

    I love this video
    I just watched it and made my player movement and its so much better than other videos
    Most other videos i would click on, check the comments, and see that they just give you a premade script or tell you what to type.
    This video has wasted hours of my life as i will have to watch your other videos because they are so helpful.
    Thank you.

  • @mr.gray_skies9419
    @mr.gray_skies9419 2 ปีที่แล้ว +1

    So, I know this has probably been asked but, I've followed the tutorial character for character and ensure all of my capitalization and symbols are exactly the same as in the video. However I cannot seem to get away from a "CS0246" error saying that the namespace name RigidBody2D couldn't be found. Can anyone offer any help or advice? Because I have no ideas, since you clearly didn't get this error in the video and I'm following along to the letter.

  • @c4nnyiyim169
    @c4nnyiyim169 2 ปีที่แล้ว +1

    nice tut liked !

  • @cookiecrayon
    @cookiecrayon 2 ปีที่แล้ว +3

    This is a great tutorial! I've been searching for a way to use addForce to move a character around and this has been really helpful! With regards to the 3 different ways of checking if the character is grounded before it can jump, is there much of a difference between using raycasts, overlaps and layer masks, and the collision detection method that you used? Is one easier to control than the other or does one perform better than the other? Thanks again for the great vid!

  • @md.jannatulnayem4328
    @md.jannatulnayem4328 3 ปีที่แล้ว

    Again....Good content. Must keep up 👊

  • @Mona-wr9xl
    @Mona-wr9xl ปีที่แล้ว +6

    I want to just say, thank you so much for actually explaining how or why things work as well as the term definitions. This is literally the only channel I felt like I was learning something new, like a lesson rather than a guide or demonstration.

    • @Dani_Krossing
      @Dani_Krossing  ปีที่แล้ว +1

      I'm glad you found them easy to follow :)

    • @GunSpyEnthusiast
      @GunSpyEnthusiast ปีที่แล้ว

      @@Dani_Krossing im getting the " Top-level statements must precede namespace and type declarations. " error and i would know if i did the code right if you pasted the code into your descripton but you didnt.

  • @staticplays1871
    @staticplays1871 ปีที่แล้ว

    thank you for explaining how the code works, you don't know how many people make "beginner tutorials" but never actually explain the functions of the code.

  • @cocoduck7745
    @cocoduck7745 2 ปีที่แล้ว

    this video solved lot of my probs, thanks man.

  • @Pescatorelreal
    @Pescatorelreal ปีที่แล้ว

    amazing video, i watched millions of videos of unity and none helped but this one was just too good

  • @yousefahmed6975
    @yousefahmed6975 2 ปีที่แล้ว

    Great Tutorial!

  • @MEGA_TREE
    @MEGA_TREE 2 ปีที่แล้ว

    Awesome tutorial

  • @Justin--ze6qq
    @Justin--ze6qq ปีที่แล้ว

    Brooo you are so good at teaching. Thank you for this

  • @user-ul9xj1hl6b
    @user-ul9xj1hl6b ปีที่แล้ว +1

    thanks this really helped

  • @DenizTheUnbeaten
    @DenizTheUnbeaten ปีที่แล้ว

    thx for everything man

  • @Gaming_Dive
    @Gaming_Dive 2 ปีที่แล้ว

    Thank you finally i can make my game!

  • @mipheus
    @mipheus 2 ปีที่แล้ว

    OMG it is perfect for my game! Thank you very much, thats a great tutorial and you can explan very logically and nicee... First attempt i guess I wrote something wrong, but now I wrote the script new and its working perfectly, Instant subscribed!
    (And Im sry if my english is bad xD)

  • @din9239
    @din9239 ปีที่แล้ว

    Thank you so much, this helped!

  • @bhartisharma139
    @bhartisharma139 2 ปีที่แล้ว

    you are extremely underrated bro. thank you sooo much

  • @GamingTube1000
    @GamingTube1000 ปีที่แล้ว

    wonderful explenetion !

  • @philipphille5048
    @philipphille5048 ปีที่แล้ว

    having tNice tutorials tutorial playing when first using soft soft was a godsend. Thank you!!

  • @akibahmed4251
    @akibahmed4251 ปีที่แล้ว

    Already subscribed, this is gold

  • @grassandgrease
    @grassandgrease 2 ปีที่แล้ว

    For some reason, when jumping it keeps flying off as long as i have teh jump butten pressed, cant firuge out why? if (!isJumping && moveVertical > 0.1f) should make it come back down right?

  • @linkdev3916
    @linkdev3916 2 ปีที่แล้ว

    this guy is so wholesome i love him

  • @javierst.claire5651
    @javierst.claire5651 ปีที่แล้ว

    This is the best free software Ive seen. Respect.

  • @mrderpyofficial21
    @mrderpyofficial21 4 หลายเดือนก่อน +1

    finally I get it, I think, it's this player movement video is better than brakeys 2d movement. It's easier and easy to understand. I love this guy.

  • @carlospinilla2940
    @carlospinilla2940 2 ปีที่แล้ว +1

    I need help with something for my own game, The code itself works fine. But the inputs moveSpeed and jumpForce are way to high for my character, is like if he was sonic. I tried changing them to a lower value, like moveSpeed to a 1f and the jumpForce to a 5f but when I did it. The player moved but only for a little bit, after a certain amount of time it would just freeze and I could only go the opposite way of the freeze, also. The jumping, after I changed the values, Did not work! Please Help me! thank you for the rest of the tutorial but I need lots of helps!

  • @lunis9066
    @lunis9066 2 ปีที่แล้ว

    thank you very much! perfect tutorial let´s help you a bit with the YT algorithm :)

  • @theoneandonlyginger6098
    @theoneandonlyginger6098 ปีที่แล้ว

    The first time i actually understand what i'm doing, thank you

  • @gleenngarejo6776
    @gleenngarejo6776 ปีที่แล้ว

    this video help me a lot for my self study THANKYOU

  • @kshitizthakur2626
    @kshitizthakur2626 ปีที่แล้ว

    TNice tutorials is the channel that made start actually creating instead of being intimidated by the software. Thanks for a new form of therapy

  • @bluecritter
    @bluecritter 2 ปีที่แล้ว

    You. Are. The. Best. This really helps :-))

  • @betsydillard3857
    @betsydillard3857 2 ปีที่แล้ว

    Specific Error message
    Assets\Scripts\PlayerMovement.cs(8,13): error CS0246: The type or namespace name 'Ridgidbody2D' could not be found (are you missing a using directive or an assembly reference?)

  • @iPokexU
    @iPokexU ปีที่แล้ว +1

    First, thanks for the tutorial! But I'm having issues with moving the character still. I don't know where I've gone wrong. For some reason I can move the character by keyboard input BUT the character keeps moving without stopping even though I'm no longer clicking on the keyboard. Do you have any ideas why? I have the exact same script so I'm not sure if it's a setting else where that I have wrong.

  • @lucasverissimo312
    @lucasverissimo312 2 ปีที่แล้ว

    Thanks Bruu

  • @counterproductivegaming
    @counterproductivegaming 11 หลายเดือนก่อน

    Just curious, when is the method OnTriggerEnter2D and OnTriggerExit2D used? I see that it works but where in the code is it executed?

  • @radiantbluewolf7436
    @radiantbluewolf7436 2 ปีที่แล้ว

    thanks for this tutorial it was the only one i could find that worked with my version of unity and not make me think "wtf is going on"

  • @jamesostrander8022
    @jamesostrander8022 2 ปีที่แล้ว

    Brackey's 2.0 baby! Nice work.

  • @localuhu8657
    @localuhu8657 ปีที่แล้ว +2

    Hey, I'm new to game development so your tutorial is super helpful but I have trouble implementing what you've shown. I think I have copied everything but I can only move to the right but not to the left why could this be?

  • @Sushi-Boy1
    @Sushi-Boy1 2 ปีที่แล้ว

    Does anybody know how to do the ray casting thing instead? I used a circle for my character and it can jump on walls. I tried almost everything I could to fic this bug.

  • @mianmasharratmurshed8790
    @mianmasharratmurshed8790 2 ปีที่แล้ว +1

    for some reason when i put the code for vertical movement it does not work on unity and it does not say any specific error how can i fix this?

  • @thedevilchild18
    @thedevilchild18 ปีที่แล้ว

    you are a good king sir 🗽