Improve your Platformer’s Jump (and Wall Jump) | Unity

Sdílet
Vložit
  • čas přidán 15. 06. 2024
  • 🎬7 Game Feel Tricks: • 7 Game Dev Tricks to I...
    How do you design a great platformer jump?
    In this game design & unity tutorial, we'll talk about the tips and tricks you can use to improve your jump and unity 2D movement, such as coyote time, double jumps, and variable jump height. Furthermore, in this unity wall jump tutorial, we'll dive into platformer wall jumps, looking at what makes a fluid wall jump and how to design one.
    🎮Demo: dawnosaur.itch.io/platformer-...
    📜Code: github.com/Dawnosaur/platform... (platformer controller & Unity demo)
    ☕ | Support me (ko-fi.com/dawnosaur)
    ═══════ 🦖My Stuff ═══════
    💬│Discord ( / discord )
    → A community that loves game creation
    📰 | Newsletter (dawnosaur.substack.com/)
    → Weekly discussions on game design, creators and stuff by me :)
    🎮│My Games (dawnosaur.itch.io/)
    → Mostly small projects made for game jams as well as COSMOS my first commercial release
    🎁My Game!
    store.steampowered.com/app/12...
    ═══════ 📚Resources ═══════
    Creating a 2D Platformer | • [Unity] Creating a 2D ...
    Ultimate 2D Platformer Controller in Unity | • Ultimate 2D Platformer...
    ═══════ ⏰Chapters ═══════
    0:00 Intro
    0:13 Faster Fall
    0:35 Jump Height
    1:03 Max Fall Speed
    1:22 Hollow Knight's Wall Jumps
    1:32 Jump Hang Time
    2:05 Bonus Air Time
    2:28 Bonus Peak movement
    2:39 Visuals
    3:09 Jump Force
    3:38 Grace Timers
    4:11 Recap
    4:30 Wall Jumps!
    5:24 Using Lerping
    5:46 Slide
    5:57 Wall Jum Design
    6:16: Ability Design
    6:46 Double Jumps
    7:13 Ability Synergy
    7:46 Next Steps
  • Hry

Komentáře • 107

  • @DawnosaurDev
    @DawnosaurDev  Před rokem +12

    📰 This year I've started a Game Design Newsletter: dawnosaur.substack.com/
    Hey! Thanks for watching any future corrections to my platformer controller will be posted here.
    🎮Demo: dawnosaur.itch.io/platformer-...
    📜Code: github.com/Dawnosaur/platform... (platformer controller & Unity demo)
    💬 Discord: discord.gg/KkcC9hVwKf
    🦚 Twitter: twitter.com/DawnosaurDev

    • @flyingdutchman2692
      @flyingdutchman2692 Před rokem

      Would be great if code link was accessible.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem

      @@flyingdutchman2692 There's a link in the description :D

    • @flyingdutchman2692
      @flyingdutchman2692 Před rokem +2

      @@DawnosaurDev Well, I know there is a link, but it's not working. 404

    • @hozuki2495
      @hozuki2495 Před rokem +2

      Truly incredible and helpful video. Love your videos and this is one of my fav one. Though this is helpful enough even for beginners like me, it would be great if you include example input values just like in your "Improve Your Platformer with Forces | Examples in Unity" video. Again truly appreciate your efforts for all these great video.

    • @Catuta
      @Catuta Před 9 měsíci

      @flyingdutchman2692, still not solved😢

  • @sathyanarayananviswanathan3770

    FINALLY, a masterpiece after decades. Keep going!!!! I love these

  • @Rotaka
    @Rotaka Před rokem +33

    It’s incredible the amount of techniques used to make a platformer fun to control, awesome video ! Adding the code examples was a great idea as well!

  • @brucelee7782
    @brucelee7782 Před 11 měsíci +32

    Man great video but I feel like half frustrated? Sometimes things are said with code snippets and sometimes without. Like give me all or nothing man

  • @joemorris423
    @joemorris423 Před 11 měsíci +6

    This video series was super helpful in making my group project for school feel a 1000 times better! The logic for accel and deccel is genius, and making the gravity scale higher only when falling made a huge impact. Thanks!

  • @curlus
    @curlus Před rokem +4

    Quick and easy to grasp the ideas without getting bogged down with code. Great vid!

  • @miserablepile
    @miserablepile Před rokem +2

    This is crazy good. Very meticulously analyzed and applied, with expertly clear explanation!

  • @madlad255
    @madlad255 Před rokem +16

    I've been eagerly awaiting the release of this video for so long now, and it turned out amazing IMO!
    I dunno if you remember, but on your last video, I commented on how the editing was a little too much and became a bit disorienting. With this video, you've definitely found a balance. I also like how you summarize everything near the end; normally I'm not a fan of repetition, but with a topic as complex as this, it can be good to get a high-level summary afterward.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +7

      Thanks so much! Really tried to focus on balancing the pace of this video, awesome to here it worked great for you!

  • @lizardltd
    @lizardltd Před rokem +2

    The hades ost in the background is so fun lol
    You made this video very well, it's clear and fun to watch!

  • @Kalilak11
    @Kalilak11 Před rokem +1

    I appreciate your code comments so much thank you! They are so helpful! Awesome job on the code and the video!

  • @XionBrown
    @XionBrown Před rokem +2

    This video was exactly what I was looking for, thank you!!

  • @early2000skid
    @early2000skid Před rokem +4

    Well edited and paced, and informative. Good stuff Dawnosaur :)

  • @minoupitou1503
    @minoupitou1503 Před rokem +2

    i've watch the first video of the series, and it greatly helped me understand how physics in unity works (and that i don't need kinematics physics to achieve a great player movement) I wanted to point out that your analysis are great, you know what you are talking about. I want to give you kudos for the wall jump approach. every time i want to make a walljump in a game i fall in a great depression cause it is so frustrating to get it right... i always choose to disable horizontal movement when doing a wall jump, never thought of just tweaking the player horizontal input speed. thanks for sharing all of these. every tips you give gets me more motivation to actually finish my celeste rip off! it sounds stupid, but great and smooth controls comes with lots of easy and small tweaks, and you pointed out a lot of them in your series. Thanks again Dawnosaur! i should have sub way earlier. wish you success in all your project!

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +2

      Thats awesome, happy these helped you out!

  • @alicegiraud8543
    @alicegiraud8543 Před rokem +3

    Wow this is an incredibly impressive and useful work! Just when I was about to abandon making a decent wall jump for my first game. Thanks a lot! Subbed and eager to watch all of your other videos, you really made my day! :)

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      Thank so much, happy to hear this helped you out!

  • @JasonWelch
    @JasonWelch Před 11 měsíci +1

    Thanks! I didn't know about the cayote time thing. Got that taken care of in a few minutes.

  • @hyper190
    @hyper190 Před rokem +2

    really underrated content, glad i found this rare gem :)

  • @brunoaltoe100
    @brunoaltoe100 Před 11 měsíci +1

    Thank you for these videos. You are awesome, man.

  • @TurtleGamesStudios
    @TurtleGamesStudios Před 28 dny +1

    I know who I'm reading notifications from now. *subscribes*

  • @turbo8628
    @turbo8628 Před 10 měsíci +3

    You do a great job at explaining things. If you could show some specifics of unity (such as showing the difference both visually and from the different cose value attached to it) think that will add more depth and understanding for the viewer.
    Subbed. Keep up the good work 👍

  • @denn501
    @denn501 Před rokem +1

    Yo this video is great!! There's so many good info

  • @pu55yEaterr
    @pu55yEaterr Před rokem +2

    I really appreciate the change in pacing since the last video was a little bit fast for me to grasp

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      That's great to hear, really tried to focus on that this time

  • @theothetorch8016
    @theothetorch8016 Před rokem +1

    This video is so HELPFUL! FINALLY!

  • @radiomuranatsu721
    @radiomuranatsu721 Před rokem +1

    Thanks for sharing! Amazing!

  • @jarusca3933
    @jarusca3933 Před 11 měsíci +1

    Man! Incredible research!

  • @nanditavenkat8368
    @nanditavenkat8368 Před rokem +1

    well explained, and extremly useful.

  • @dobydaoud3346
    @dobydaoud3346 Před rokem +2

    Thanks dawnosaur for your tip soon I'II work at my dream game with nintendo :D

  • @sadsadsad5000
    @sadsadsad5000 Před rokem +1

    great tutorial!

  • @Paruthi.618
    @Paruthi.618 Před rokem +1

    awesome video, thanks

  • @BABAPLAYTOOMUCH
    @BABAPLAYTOOMUCH Před 11 měsíci +1

    Incredible video 🙏🙏🙏

  • @itaymadeit6069
    @itaymadeit6069 Před rokem +1

    Great Video!

  • @Ringocos
    @Ringocos Před rokem +2

    He's back!

  • @markorossie9296
    @markorossie9296 Před 8 měsíci

    Thank you!

  • @lloydkuijs
    @lloydkuijs Před rokem +1

    Great video

  • @TripFAU
    @TripFAU Před 7 měsíci

    Great video, it's helped me a lot in my coding!
    I was wondering if there would be a way to alter the script so that the player character's direction changes based on rotation so that the x axis always faces the way the player is looking - rather than by flipping the x-axis as the code is currently written

  • @loupandsnoop
    @loupandsnoop Před 11 měsíci +1

    Nice video. I tried your code. Most of it works great, but I found a pretty major bug.
    1) If ground hitbox doesn't cover whole player, you can be stuck jumpless on edges.
    2) If ground hitbox is wider to cover floor, then you can clip into walls => normal jump on walls.
    My solution was to make the ground hitbox wide, and make sure you are grounded for at least 3 physics frames in a row before attempting any normal jump. This way the physics engine has time to eject you from a wall.
    Deets: I make a private int continuousGroundedFrames. In FixedUpdate, if grounded, continuousGroundedFrames++. In Update, only give coyote time if you've been grounded for 3 physics frames continuously. When jumping, set continuousGroundedFrames to 0. To walljump condition, add "and not grounded" to prevent jumpbuffer from giving walljumps on floor.
    I know it's been a while, but I hope this helps. Cheers.

  • @Guts___
    @Guts___ Před rokem +3

    I used ur example code and it works really good and i feel like i learned a lot about movement from your videos, i really appreciate the free education you are providing, Thank you very much. But i have one question, is there a possibility to get some example values for the jump ? Like you did in one of your other videos, for the "Run" where you showed what values you used to come close to a ceartain move style of a game.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      Thanks a lot! If you dowload the unity demo from Git Hub you can have a look at the jump values I thought fit a Celeste, Hollow Knight and Super Meat Boy style character. You can find all the values under the "scriptable objects" file

    • @Guts___
      @Guts___ Před rokem +1

      @@DawnosaurDev oh this is super nice, im gonna check it out immediately, Thank you :D

  • @thefunnybuddy4138
    @thefunnybuddy4138 Před rokem

    One thing I've noticed is when you have a double jump and jump buffer, you could end up using a double jump instead of a jump buffer. Once you're airborne you'll try to double jump but can't since you technically already used it.

    • @loicpernot8779
      @loicpernot8779 Před 11 měsíci +1

      I'm sure you figured out how to fix that already, but just in case someone else sees this: you can simply set your jump buffer timer to be over as soon as you perform the first jump. Similarly, you can prevent an accidental double jump by adding a buffer check gameobject below the one that checks if you're grounded. This way, jump buffers are only allowed if you're close to safe ground.

  • @moelow5385
    @moelow5385 Před 10 měsíci +1

    incredible video, I find myself coming back to it many times!
    just wanted to ask how does the player data script work? is it a separate script referenced in the player controller with all the variables set to public?

    • @DawnosaurDev
      @DawnosaurDev  Před 10 měsíci +1

      So the Player Data is this thing called a Scriptable Object. It works pretty much as you've described. They way you use it, is by creating a new asset inside your project (there you be an option at the top for Player Data) then you can use this to set all of your movement parameters. I'd recommend Brackey's video on the topic. Let me know if you need any more help, thanks!

  • @blackdevilb
    @blackdevilb Před 2 měsíci

    Great fucking video, thank you

  • @KebxaiAod
    @KebxaiAod Před rokem +1

    Hello, i don't know how to implement player animations in this script. Can you say where i put the animator variables, how to check if player is moving and etc?

  • @Shinos_99
    @Shinos_99 Před rokem

    Your videos helped me so much, this is a smack to the face to all the people saying that you cannot build a nice platformer controller with built-in physics, this is excellent.
    PS: did you manage to get slopes working right too?

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +2

      Haven't tried slopes yet, but I believe other have had some success! From what I've seen it's kind of difficult to get the acceleration to feel natural on a slope but definitely doable :D

    • @Shinos_99
      @Shinos_99 Před 11 měsíci +1

      @@DawnosaurDev would be really cool if you'd ever look that out too a lil in some video, keep your good work!

  • @timel11xgdsideswap
    @timel11xgdsideswap Před 4 měsíci

    Great tutorial and it also helped me a lot to think how i actually want my game to be. Although I have 1 problem: I have copied and changed some code to make it fit my game and everythings seems to work perfectly fine but when i open the game to test and press teh jump button it doesn't actually jump. It just resets the jump timer. Anyone knows how to fix this please?

  • @nonamee69420
    @nonamee69420 Před měsícem

    awesome video, many thanks! what is the game at 3:24 by the way?

  • @trashcaster
    @trashcaster Před rokem +1

    What's the game at 5:11? It looks really cool
    Edit: Screenshotted and used Google search by image, the game is Ori and the Will of the Wisps

  • @trip7141
    @trip7141 Před rokem +1

    Just something I've been thinking about, is it common to see games use an equivalent of coyote time and jump buffering for wall jumps? I'm thinking of something like a situation where you bounce off of two closely spaced walls to scale a narrow passage. Coyote time seems like it would give the player a short grace period if they fall off the wall to make the jump to the opposite wall. Buffering doesn't seem like it would be as useful because I can't recall any games where you'd get penalized for hitting the jump button too early in that situation, but it still might come up.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      Yeah, I'd say so. It's probably not used as much as normal coyote time but I'd it's pretty common as well :D

    • @trip7141
      @trip7141 Před rokem

      @@DawnosaurDev Thanks for the response! It took a little fiddling off and on over the span of a few days but I got both working well for wall jumps too and it helps the feel massively!

  • @Derkells
    @Derkells Před 8 měsíci

    How do I create the Player Data Object? I don't have the option to create that. Is it something I have to create myself? If so, how do I do that?

  • @wafflydig2457
    @wafflydig2457 Před rokem +1

    Hi Dawn thank you so much for the code and tutorial very informative!
    Is there any chance you could show/tell where in the code to switch animation parameters set up in the animator? I think a simple idle, run, jump and fall would do a lot of people wonders.
    In my case I have an idle and jump parameter setup correctly but am having problems getting a "running" boolean to turn to true while on ground. (Strangely it seems to work after a jump though).
    Regardless thank you so much for the hard work you clearly put into this

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      Hiya!
      So I would say the best place for your animation parameters would be I the update loop where the movement functions are called. For example I would put an animation Trigger call for jumping/wall jumping where we call those functions.
      For the running or and idle animation I would (like you said) have those as books. Here I would probably do a few extra checks. First where were calling the run function I would add in an if statement checking the move input. Based on this you could then set the animation to a run or idle. I'm thinking you might also want some more checks to see if we want to play say a jump or falling animation instead for example. Or alternatively add in a stop animation.
      I hope this can give you some pointers and starting ideas. Overall however it largely depends on your animations.
      Lastly if this is a larger project I'd also recommend controlling the players animations through another class. Similar to what I did in the GitHub project.
      Hope this helps thanks!

    • @wafflydig2457
      @wafflydig2457 Před rokem +1

      @@DawnosaurDev Hi Dawn, thank you so much for the reply I really appreciate you taking the time to help me out and I'm happy to say I've got it all working now! Very excited, having working animations really brings the whole thing to life and now I have proper Idle, running and jumping animations that all look and feel nice! I did handle the transition to run a little differently by using a float that picks up on the movement detected on the horizontal axis and using Mathf.Abs to convert the negative value to a positive one. Then I used the Animator to switch running to true when I am grounded (not jumping) and that new float value was > 0.1 and transition back to idle when grounded and the running float value < 0.1.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      @@wafflydig2457 That's awesome, no worries!

    • @danbam9018
      @danbam9018 Před rokem

      Hello
      Can you tell me how did you do the jump animation? Im struggling with the code.

    • @wafflydig2457
      @wafflydig2457 Před rokem

      ​@@danbam9018 Hi Dan. There is a little more to it than coding, you also need to do some work in Unity. I'm not sure exactly where you are in the process but generally speaking I have the animator set up using two conditions. First a condition I called "grounded" which is a boolean I set to true or false depending on whether Dawn's collision detector was touching the ground or if I know we are not supposed to be on the ground. If we are supposed to be on ground this is set to true. If not it is set to false.
      The other parameter I'm using is called "horizontal" and this is a float that is set to Mathf.Abs (Input.GetAxisRaw("Horizontal") If a player lands from a jump (setting onGround to true) and horizontal is >0.1 I'll have the player transition from jump to run. Other wise they transition to idle.
      I use a separate script called AnimationController for handling changing all of these conditions depending on player input. I'm also using Unity's Input System. The AnimationController script is defined in the variable section and called in the awake section of the movement script.
      There are a series of if statements in the AnimationController script that trigger these conditions. When I want to update a variable in that script I'll write (in the movement script): "AnimationHandler.onGround = true; " which will go to my AnimationController script and set the onGround variable in that script to true. In the AnimationController script I have an if statement that says when onGround is true set the "grounded" condition to true. else set it to false.
      It was very daunting to me learning this so I can relate to the struggle but keep at it! I highly recommend looking up all the tutorials you can get your hands on, even if they do not directly do exactly what you want to do you may still learn some handy code.
      Tarodev and Brackeys are very good off the top of my head. I've also asked ChatGPT a number of questions and was pleasantly surprised how helpful it's been. GMTK isn't exactly for writing code but Mark has some excellent videos about his experience and the early videos are more about him getting work flow down and are particularly interesting.
      The best advice I have is to break down your problems as small as possible and look up how to do one of them at a time. Debug.Log(stuff to check); is your friend. It's not easy, it's not always fun but you've gotta have some faith and put in the work and do it consistently. You got this and I hope this got you a little bit closer to your goal!

  • @nthh6099
    @nthh6099 Před rokem +1

    hey, what is vs code theme u are using? at 3:08
    that's insanely good looking🙂

  • @zorroinfernal4087
    @zorroinfernal4087 Před rokem

    you have video of dash in games?

  • @daniinkidar99
    @daniinkidar99 Před rokem +1

    More videos like this and the channel will boom I promise.

  • @PaonSol
    @PaonSol Před rokem +1

    Thank you for this! Excellent stuff.
    I'm curious how hard this would be to convert into 3D platforming? There is so very little stuff about Unity 3D platforming on CZcams...
    Edit: Well, I tested it, and I can jump infinitely, so it's kinda broken.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem

      It's definitely doable. I believe I tried it out and got some really cool results, however there's a lot more vector math involved that you'll need to use combined with what's in this video. I think Dani's movement tutorial might use some similar techniques for movement as I do, so that may be a great starting point.
      Good luck!

  • @TheSleepKing
    @TheSleepKing Před 6 měsíci

    I am really not understanding the ground and wall checks. My character still won't jump. Is there something I'm doing wrong? (Based on debug, the input for jump works, but the ground and wall checks are not detecting anything.) Also, my character feels slippery despite the change of values.

  • @Sllendar
    @Sllendar Před 11 měsíci

    Hmm, at 0:30 You're talking about increasing gravity scale at peak of the jump, but at 2:05 You're talking about lowering the gravity at the peak of the jump. So this techniques should be used separately or there is a way to combine them?

  • @gebakkesushi4511
    @gebakkesushi4511 Před rokem

    Can someone help me? I downloaded the scripts and imported it to my scene and i copied the celeste example to see how it feels and to change it from that, but my character doesn't move or fall or anything. How can i fix it?
    Update: My player now moves but it falls over everytime and i cant jump before falling over

  • @loop3454
    @loop3454 Před rokem

    can you do soundtrack next?

  • @kardokdelikaya9570
    @kardokdelikaya9570 Před rokem +1

    Do you plan to make a video about moving platforms?

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +1

      Not planning to make any more videos on platformers for a while sadly : (
      I've struggled with moving platforms myself. I believe the method I've used in the past was to use OnCollisionEnter and Exit to check when the player touches a moving platform and then try and then try and orient their position around the platform. Might be tricky to get working with acceleration though good luck!

    • @kardokdelikaya9570
      @kardokdelikaya9570 Před rokem +1

      @@DawnosaurDev I actually think I did a good job on changing some parts of your code. I added wall climb and hang too. Thanks a lot for this code.

    • @DawnosaurDev
      @DawnosaurDev  Před rokem +2

      @@kardokdelikaya9570 Neat, that sounds awesome

  • @felipezymor9970
    @felipezymor9970 Před 4 měsíci

    I noticed that when we press jump two times fast, the character jumps so much higher than the double jump expected height. Has anyone fixed that?

  • @brucelee7782
    @brucelee7782 Před 10 měsíci

    Anyone managed to implement this script into their own game? My player's x and y velocity keeps changing for some reason even though im not moving

  • @darwisybaqir5877
    @darwisybaqir5877 Před rokem

    question, i might've missed this when watching the video, but what is the code format for the script you shown in the video?
    python or C#???

  • @JakeTheJay
    @JakeTheJay Před rokem

    My jump doesn't work for some reason. The key detection works but the jump function doesn't seem to be called when I press the button. I triple checked to make sure my code was exactly the same and I am just confused as to how this is happening.

    • @JakeTheJay
      @JakeTheJay Před rokem +1

      Ok I found out what my issue was. Layers and tags were being dumb.

  • @ShaktiUtada
    @ShaktiUtada Před 6 měsíci

    im not understanding what is happening. I cant move, jump or do anything

  • @godzil7
    @godzil7 Před 8 měsíci

    HAWLLOW KNIFT?

  • @jusminyip8915
    @jusminyip8915 Před 4 měsíci

    1:58

  • @dmas7749
    @dmas7749 Před rokem

    uses old input manager, trash /s
    tried the demo but i found you could jump in the Super Meat Boy by pressing jump before landing, however, if i released the button before landing as well, i would get a full jump, and a rewrite using the new input system would be better

  • @Khang-lt4gk
    @Khang-lt4gk Před 11 měsíci

    xin code

  • @emeraldcubegaming8018
    @emeraldcubegaming8018 Před 11 měsíci +1

    All of your videos are amazing, and I appreciate your work as well as the fact that it's free. However, I wanted to ask something. When adding your double jump code to your given Player Movement script, I got four compiler errors all relating to the same thing; the variables weren't given any definition / they don't exist. I assume there's is an easy fix but since I'm pretty new to game making, I don't know what to do. Can you help me on this one? Much appreciated @DawnosaurDev