How to make Super Mario Bros in Unity (Part 2) - Movement/Physics

Поділитися
Вставка
  • Опубліковано 15 лис 2024

КОМЕНТАРІ • 100

  • @Zigurous
    @Zigurous  2 роки тому +5

    Visit the GitHub page for the most up to date source code: github.com/zigurous/unity-super-mario-tutorial
    View the FAQ for answers to common questions: github.com/zigurous/unity-super-mario-tutorial/wiki

    • @theanimationstation9644
      @theanimationstation9644 2 роки тому +2

      Oh I wish I read this first, was looking for the reference for 1-1, I ended up putting an overlay of 1-1 scaled best I can and basically lined it up that way 😆🤪

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

    Fantastic tutorials, for me learning practical stuff is much more useful than dry theory with documentation, and the way you break the whole game into small digestible pieces, and how eloquently you explain each part and connect it all together is just fascinating. Huge props for your organization and explanation skills, they're exceptional

  • @humongouserectus
    @humongouserectus Рік тому +7

    @Zigurous,
    This series of videos is amazing. There is nothing better than re-creating classic games in Unity. I have learned so much already. It's straight to the point and explained very well. Thank you for putting in the time and effort to create such exceptional content. You sir, are a gentlemen and a scholar! 👍

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

    This is way better than UNITYs own teaching/training videos. I understand how you explain things way better.

  • @pistacchioso
    @pistacchioso 2 роки тому +10

    Hi Zigorous and thanks for those videos. I honestly think they are the best Unity resource on UA-cam right now. If I may make a suggestion: write much less code before showing the result. Eg: you wrote the jump functionality all at once. Since it’s a complicated peace, it would work better if you showed when it DIDNT work ok. “Ok, see, Mario jumps, but you can keep jumping in middle air. Add a check to see if it’s grounded” ”Now he jumps, but it doesn’t fall down, see? Let’s code that.” “Now, as you can see, it falls down, but the physics are a bit off. Let’s add a multiplier”. And so on.
    This would greatly help to understand WHY the things are done the way they are done!
    Thank you for your time :)

  • @mielivalta
    @mielivalta 9 місяців тому

    Whoa, amazing! This teaches so much about programming, C# and Unity. The explanations are clear, voice is good and calm. Pacing is excellent. Top quality video!

  • @keithfay9328
    @keithfay9328 3 місяці тому

    Great video, learned a lot. Just finished the video, no bugs, no problems, worked perfectly

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

    Zigorous, your content is high quality teaching and all, but I wish I could show you how my smile faded when I realised the next tutorial was 2 HOURS💀💀

  • @cammyposey5054
    @cammyposey5054 10 місяців тому +8

    My Mario won't walk. All he does is stare at my soul.

  • @ploopy-moddedminecrafttuto8560
    @ploopy-moddedminecrafttuto8560 2 роки тому +21

    How would we prevent the wall velocity glitch for the camera barrier? Since we are doing this in the movement without a collider we can not use the raycast extension for the rigidbody.
    Edit: I found a solution! Replace the clamping code with these lines:
    Vector2 tempPos = position;
    position.x = Mathf.Clamp(position.x, leftEdge.x + 0.5f, rightEdge.x - 0.5f);
    if (position != tempPos) { velocity.x = 0f; }

    • @GamingBox-mg7ml
      @GamingBox-mg7ml Рік тому

      Tbh I found an easier solution by making a wall as a child in camera. The wall has a box collidor and when the camera moves it moves with it.

  • @yazanjordan3103
    @yazanjordan3103 2 роки тому +2

    this is a great tutorial i think u need to check the mario slide when he slide he turn his face to where he is going not forward

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

    EDIT: WATCHING MY CHARACTER MOVE FOR THE FIRST TIME WAS INCREDIBLE!!! THANK YOU!!!
    Watching Mario move left to right at18:30 for the first time was extremely exciting! You should have added some game noises to video here and there! This is wonderful! Thank you so much for doing these tutorials!

  • @abg2487
    @abg2487 2 роки тому +2

    Next tutorial make on UI menu and how to do transition between those levels scene . And make level selection menus..
    Some animations using DoTweeen package to animate the UI button..?

  • @alienouz
    @alienouz 2 роки тому +4

    thanks for the nice video.
    I think you should use the new input system in your projects,

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

    In general you are good bro, in fact, I have learn many things with your tutorials and tips, really cool. The problem is not what you show, is that some things doesn't work in my side xD but I'm already fixing it. Hope to see more videos of yours after finishing the series.

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

      Everything is working here

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

      Same i dont know what i did wrong in gravity section but the jump isn’t accelerating or influenced by me holding down space

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

      @@usercontent2112 yeah, I did it too nwn

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

      @@zombiegamer1069 I have that code somewhere in my PC, let me finish with my work and I will see what could be happening

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

    58:48 I would love to correct a small mistake here, which is that the dot product itself doesn't give those values (-1,0,1) but instead its the cosine in the dot product formula, let me explain further
    so we have two vector belonging to R^n ( to any dimension, in this case 2d (R^2) or 3d (R^3) ) called U and V
    U . V (U dot V)= ||U|| .||V|| .cos (U,V)
    ||U|| length of vector U
    ||V|| length of vector V
    (U,V) the angle between the vectors U and V
    so the operation U.V is going to give a scalar (normal number not a vector) that belongs to R
    But cos (U,V) would give a number between -1 and 1, which is used to tell the directions of the 2 vectors compared to each other the way u explained it
    1:00:18 I did a little search about unity's dot operator, and it does give off a result of a normal algebra dot operation, unless the vectors are normalized, in that case, it would return the results u have mentioned

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

    Great tutorial Unity Sensei

  • @celinedrules
    @celinedrules Рік тому +2

    You set the x velocity to 0 when you are running but hit an obstacle such as a wall/pipe. However if you go back to the left and hit the edge of the screen but not an obstacle, the velocity doesn't get reset back to 0.
    Also, what about fast running like you are holding down the b button?

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

    Hi Adam thanks a bunch this video's are really helpful

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

    Hi, zigorus! been a fan since you started making tutorials on unity... I really am looking forward to completing this game after my last one! bye!

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

    Nice vid man keep it up

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

    Can you make 2d zombie survival game tutorial?

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

    my camera is not moving and i did everything as the video said :( i even tried to change the "LateUpdate" to "Update" but didnt work

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

    Sir can we use this asset for publishing on Google play ???

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

    When is the next part out?? I can’t wait

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

      ua-cam.com/video/BwilJ4ExljQ/v-deo.html

  • @GaBoyInKy
    @GaBoyInKy 7 місяців тому

    Thank you.

  • @toliiedits
    @toliiedits Рік тому +2

    Please someone help me! After coding jumping and gravity my Mario just starts to fall way down for infinity like there’s no collide between ground and Mario what’s I did wrong and what can I do to fix it!

    • @PhucTran-oi1br
      @PhucTran-oi1br Рік тому +3

      maybe when you applied "tiled drawing" to your groundblocks, you forgot to adjust its box collider to fit the whole sprite. check it

  • @adamabbott2014
    @adamabbott2014 2 роки тому +2

    Hi, many thanks for your video. it is amazing for me. i have one question about movement in X. when i typed the code about jump, it is found the movement in X never working. it can be moved in X when jump is activated.

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

      the code "velocity.y = Mathf.Max(velocity.y, 0.0f)" is typed, and the move in X is working. i cant understand what is problem. this is contol Y.

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

      I'm not really sure how that line of code could cause your X movement to stop working unless you mistyped something elsewhere in the code. This one line of code is only affecting the Y velocity, so there's got to be another problem somewhere else.

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

      @Adam Abbott did you find a fix for this mine has done the same !

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

    34:03 OH NO
    I'm not supposed to be here

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

    for some reason my jumping doesn't work, i followed the code but idk what's wrong

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

      ok jumping works now but when it hits an enemy it keeps the jumping animation on

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

      I'm having the same jumping issue! How did you solve it ?

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

      @@lovingCJ3 the jumping stopped working again 🥲

  • @MIGUELSANTOS-jw5ys
    @MIGUELSANTOS-jw5ys Рік тому

    hello guys may I ask what algorithm for movement is been used in this Mario gameplay?

  • @eCircuit-Code
    @eCircuit-Code 5 місяців тому

    thank u

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

    Help me please. I did everything as in the video, but when the project starts, the camera does not see the character, the level itself is simply displayed, without the character.

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

    39:06 - I can't add the 3rd layer, it can't be changed in any way, what can I do with it?

  • @garazul4291
    @garazul4291 9 місяців тому +1

    If you're like me and you don't like the long time of Mario coming to a full stop, you could do this:
    public float friction = 2f; //whatever feels good to you
    velocity.x = Mathf.MoveTowards(velocity.x, inputAxis * moveSpeed, moveSpeed * friction * Time.deltaTime);

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

    😍Nice Work!

  • @MuhammadIshaq-px9cf
    @MuhammadIshaq-px9cf Рік тому

    sir can i use assest and publish game

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

    I've been following along but as soon as we got into the sprites and animation I've encountered a few errors. The first is that even though I've been doing everything with smaller Mario, my sprite now defaults to the Super Mario. But then with the slide sprite it seems to want to stick on slide after it plays and doesn't snap back the way it should. It also is quite delayed.
    Edit: Figured it out. I had misplaced a greater than sign and changed it up, so it was throwing me some crazy stuff. Also, for some reason I had turned back on my Super Mario which brought both of the Mario states up. Figured it out though!

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

    Cool!

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

    This isn't really a problem, but my VS code doesn't display colors like yours for stuff like Mathf or whatever when the code is definitely correct, how do i change the settings inside VS code to match yours?

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

    I've followed all the directions and for some reason I can't get Mario to move? what do I Do?

    • @cammyposey5054
      @cammyposey5054 10 місяців тому +1

      I'm having this happen to my Mario too!

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

    Love it ♡

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

    Hey, i'm new to all this and learning c# coding and using unity as i go. I have a problem though.
    The menu that is under scene with the 2d and light bulb is not there on mine. Is it an error, do i need to download something else?

  • @doctoryoyogaming5122
    @doctoryoyogaming5122 2 роки тому +9

    Nintendo: NOOOOO WE CANT EARN MONEY NOW THE GAME IS BEING MADE IN UNITY

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

    Is watching this type of unity tutorial is worth... Later can I make my own games and be a problem solver .....

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

      Watching tutorials can help you learn new techniques that you can apply to your own games, but it still requires you to practice your skills. You'll become a better problem solver by making your own games and trying to work through the problems that come up. You'll get better at it the more you do it.

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

      @@Zigurous Next tutorial make on UI menu and how to do transition between those levels scene . And make level selection menus..
      Some animations using DoTweeen package to animate the UI button..?
      And making mobile responsive design game ....

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

    When my player gets larger, Mario, he can't jump. Do any of you know how to make the large Mario jump?

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

    Is anyone else's Mario running into an invisible wall at a certain coordinate? I have rewrote the whole program and still am having this issue. I'm a C# ASP dev and cannot seem to find where in the camera script this is happening. Any help would be appreciated!

  • @DavideCintia-o7x
    @DavideCintia-o7x Рік тому

    hi thanks for the really well done video, I tried all the procedures but the player doesn't jump it just goes forward or backward, the only way to make this work was to activate the "is trigger" option but by doing so the character collapses into the empty downwards

    • @DavideCintia-o7x
      @DavideCintia-o7x Рік тому

      could you tell me how to solve it? I thank you in advance

    • @drellreacts6661
      @drellreacts6661 8 місяців тому

      Have you ever figured it out. Having the same problem

    • @SpinelliRecensioni
      @SpinelliRecensioni 5 місяців тому

      @@drellreacts6661 I solved it using the space, however check your jump key in the input manager

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

    i dont understand any of this code like what is transform and why do you type this transform transform lol

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

    Horizontal movement didnt work for me (I tried many times)

  • @VootOfYoutube
    @VootOfYoutube Місяць тому

    At 1:36:50 he changes Sprite to AnimateSprite. When I do this, I have an error CS0246 "The type or namespace name 'AnimateSprite' could not be found (are you missing a using directive or an assembly reference?)". Does anyone know the solution to this?

    • @VootOfYoutube
      @VootOfYoutube Місяць тому

      I figured it out. He uses AnimatedSprite, what works is using AnimationScript.

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

    Hey I tried this tutorial and it was great but my Mario is not walking it starts rolling when I make it move so can any one help me for this

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

      On the Rigidbody2D under constraints, did you freeze the rotation?

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

    If there is another person in the comments that also knows how to code, can somebody please tell me how to fix Mario's run animations? It keeps saying that something is wrong, and I double checked my work.

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

    Another great tutorial. I’m curious why, since you’re applying movement manually rather than manipulating the rigidbody via apply force, why you didn’t just apply the movement to the transform?

    • @BitbeastGames
      @BitbeastGames 2 роки тому +2

      Because the ridgidbody is the physics object that is used in the collision calculations. If you move the transform directly the collider might not move in the same frame with the transform (because physics updates have a different frame rate) and you can get weird behavior from that.

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

    i don't know if you're still responding to the comments or if someone here can explain it to me but for the head collision i tried to make use of the static raycast function but with vector2.up and it didn't work.Anybody got a clue ? i want to essentially create a circle collider at the head of mario and check if his head bump into object,isnt that better than using the whole body collider ?

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

    uhh so i cant see mario when i press play, anyone know why?

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

      do you have the answer same here, my mario is just falling infinitly

    • @КристинаКоручева
      @КристинаКоручева Рік тому +1

      I had the same issue where my mario was falling down infinitely after pressing play. The problem was that my collider for the ground blocks was not placed correctly. Idk if this will help but I hope you found a solution otherwise.

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

      @@КристинаКоручева thanks

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

    27:49

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

    lets goooo

  • @GeraldFord-r5g
    @GeraldFord-r5g Рік тому

    My Mario's head is sticking to the blocks like a magnet, he can move and when moving out from under the block he falls to the ground. In the debugger I noticed it registers him as grounded when his head touches the underside of the block. Anyone know why?

    • @PhucTran-oi1br
      @PhucTran-oi1br Рік тому

      check the radius and distance inside Raycast, you should first set the boxcollider size to 0.25, and then measure its way down to the ground block, see how much the Y value changes, which should be the value of the float distance i mentioned above.
      By doing so you limit the collider area of your mario to the bottom half of his body instead of from head to toe.

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

    When I add the raycast bool in the playermovement script it says that the rigidbody.Raycast doesn't exist

    • @Alone....7n7
      @Alone....7n7 Рік тому

      Same broo
      Your prob is solve ??

    • @Alone....7n7
      @Alone....7n7 Рік тому

      Any solution bro

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

      ​@@Alone....7n7 I don't know

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

      gotta have the Extensions file in the same folder as your movement script

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

    (*help)
    Done till 50:01 added everything side scrolling , player movement and extension now my character is not moving and there is no error, earlier the character would move left and right and camera as well
    (*help)

    • @Dev-A-Dims
      @Dev-A-Dims 10 місяців тому

      same issue with me brother

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

    I had problems with the running animations, every time when i stopped running and started running again it seemed like my framerate doubled. I fixed this by changing the OnEnable function with the start function. Does anyone have a idea why this happened?

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

      after 2 hours of searching i found out that I wrote Ondisable instead of OnDisable.

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

    Bro you forgot the fire flower

  • @anuraagchandra2548
    @anuraagchandra2548 Місяць тому

    My Mario isn't moving left or right. Neither does he jump. Please help!