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

Поділитися
Вставка
  • Опубліковано 2 чер 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
  • Ігри

КОМЕНТАРІ • 107

  • @DawnosaurDev
    @DawnosaurDev  Рік тому +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 Рік тому

      Would be great if code link was accessible.

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

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

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

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

    • @hozuki2495
      @hozuki2495 Рік тому +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 9 місяців тому

      @flyingdutchman2692, still not solved😢

  • @brucelee7782
    @brucelee7782 10 місяців тому +31

    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

  • @Rotaka
    @Rotaka Рік тому +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!

  • @joemorris423
    @joemorris423 11 місяців тому +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 Рік тому +4

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

  • @sathyanarayananviswanathan3770
    @sathyanarayananviswanathan3770 Рік тому +15

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

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

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

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

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

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

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

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

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

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

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

  • @turbo8628
    @turbo8628 10 місяців тому +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 👍

  • @minoupitou1503
    @minoupitou1503 Рік тому +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  Рік тому +2

      Thats awesome, happy these helped you out!

  • @madlad255
    @madlad255 Рік тому +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  Рік тому +7

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

  • @brunoaltoe100
    @brunoaltoe100 11 місяців тому +1

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

  • @alicegiraud8543
    @alicegiraud8543 Рік тому +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  Рік тому +1

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

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

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

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

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

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

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

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

    Thanks for sharing! Amazing!

  • @jarusca3933
    @jarusca3933 11 місяців тому +1

    Man! Incredible research!

  • @Paruthi.618
    @Paruthi.618 11 місяців тому +1

    awesome video, thanks

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

    This video is so HELPFUL! FINALLY!

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

    great tutorial!

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

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

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

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

  • @BABAPLAYTOOMUCH
    @BABAPLAYTOOMUCH 11 місяців тому +1

    Incredible video 🙏🙏🙏

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

    Great Video!

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

    well explained, and extremly useful.

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

    He's back!

  • @TurtleGamesStudios
    @TurtleGamesStudios 15 днів тому +1

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

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

    Thank you!

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

    Great video

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

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

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

    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

  • @Guts___
    @Guts___ Рік тому +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  Рік тому +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___ Рік тому +1

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

  • @moelow5385
    @moelow5385 10 місяців тому +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  10 місяців тому +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!

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

    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  Рік тому +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 10 місяців тому +1

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

  • @loupandsnoop
    @loupandsnoop 11 місяців тому +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.

  • @KebxaiAod
    @KebxaiAod 11 місяців тому +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?

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

    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 10 місяців тому +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.

  • @trip7141
    @trip7141 Рік тому +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  Рік тому +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 Рік тому

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

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

    Great fucking video, thank you

  • @wafflydig2457
    @wafflydig2457 Рік тому +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  Рік тому +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 Рік тому +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  Рік тому +1

      @@wafflydig2457 That's awesome, no worries!

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

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

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

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

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

    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?

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

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

  • @trashcaster
    @trashcaster Рік тому +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

  • @nonamee69420
    @nonamee69420 23 дні тому

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

  • @PaonSol
    @PaonSol Рік тому +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 UA-cam...
    Edit: Well, I tested it, and I can jump infinitely, so it's kinda broken.

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

      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!

  • @Sllendar
    @Sllendar 10 місяців тому

    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?

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

    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?

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

    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#???

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

    you have video of dash in games?

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

    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.

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

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

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

    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

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

    Do you plan to make a video about moving platforms?

    • @DawnosaurDev
      @DawnosaurDev  Рік тому +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 Рік тому +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  Рік тому +2

      @@kardokdelikaya9570 Neat, that sounds awesome

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

    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 Рік тому +1

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

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

    can you do soundtrack next?

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

    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?

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

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

  • @brucelee7782
    @brucelee7782 10 місяців тому

    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

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

    HAWLLOW KNIFT?

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

    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

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

    1:58

  • @Khang-lt4gk
    @Khang-lt4gk 11 місяців тому

    xin code

  • @emeraldcubegaming8018
    @emeraldcubegaming8018 11 місяців тому +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