How to Jump in Unity 3D: Fixing the Velocity Verlet Integration [Built-In Character Controller #4]

Поділитися
Вставка
  • Опубліковано 10 лип 2024
  • An updated explanation of how to jump in Unity3D and how to use Velocity Verlet Integration to make the most consistent jump for your game! We'll do so by fixing the current implementation from this series!
    Mistakes happen! And thanks to this amazing community, I've been able to make a video explaining and fixing a minor issue with our jump from the last episode in the Built-In Character Controller series! Thank you Peonso!
    ACCESS PROJECT FILES & SUPPORT THE CHANNEL:
    💛 / iheartgamedev
    iHeartGameDev Merch:
    💛 www.iheartgamedev.com
    WANT MORE?
    Interested in learning more about character controllers in Unity? Check out the rest of the tutorials in this series:
    ✅ • Character Controllers
    ✦ Like the vid? Please consider Subscribing!
    bit.ly/2YdIb6j
    ✦ Missed out on the last episode?
    • How to Jump in Unity 3...
    SOCIAL:
    ✦ Discord
    / discord
    ✦ Twitter
    / iheartgamedev
    LINKS FROM THE VIDEO:
    🤖 Download Jammo for YOUR game:
    assetstore.unity.com/packages...
    ⭐ And Check Out @Mix and Jam !
    / mixandjam
    🌐 Learn about Jumping
    www.youtube.com/watch?v=hG9Sz...
    lolengine.net/blog/2011/12/14/...
    ⭐ Kyle Pittman
    / piratehearts
    GEAR:
    Lumix G7 Camera: amzn.to/3Kks1gZ
    Epomaker GK68 Keyboard: amzn.to/3Ke87EB
    Samson C01U Pro Mic: amzn.to/33kDdtG
    LG 27" Monitor: amzn.to/3qAHFwS
    Lepow 15.6" Portable Monitor: amzn.to/3287OtL
    Logitech G604 Mouse: amzn.to/3A6jNV4
    Audio-Technica ATH-M50X Headphones: amzn.to/3tBaeMT
    X-Pen Artist 15.6 Pro Drawing Tablet: amzn.to/3FE5HLI
    Apple 15in MacBook Pro Laptop: amzn.to/3AbKdFc
    ►TIMESTAMPS:
    Intro: 0:00
    Recap: 0:35
    Why Velocity Verlet: 1:12
    How does Velocity Verlet Work: 1:42
    Our current Script Implementation: 2:16
    Our current mistake: 2:50
    Mistake Summary: 3:25
    THE FIX part 1: 3:48
    First Attempt: 5:47
    THE FIX part 2: 5:55
    The Result: 6:18
    Last note: 6:30
    Outro: 7:06
    THANK YOU PEONSO: 7:30

КОМЕНТАРІ • 46

  • @iHeartGameDev
    @iHeartGameDev  2 роки тому +26

    Hey all - This video would not have been possible if one of the awesome members of this community! So shoutout to Peonso for being able to help me see, understand and fix my mistake from the last video! Be sure to show him some love!
    Cheers! 🍻
    -Nicky

    • @peonso
      @peonso 2 роки тому +7

      Thank you Nicky for the shoutout and the awesome content once again, I'm happy to make a small contribution, giving something back from where I took soo much. The entire series and the animation one teached me a lot.

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

      Also doing a shoutout cause this content is amazing. The jumping is a bit too complex for me to fully understand still, but you're making it at least approachable from a high level. It's hard to find someone that can teach a beginner (like me) and actually be beginner friendly. You'd be surprised how many "beginner" tutorials teach the content as if you've already been developing in Unity for 6 months to a year and have a photographic memory allowing you to use a feature once and remember every single detail about where to find it, how to to use it, and how to use it in code. Thanks for all the hard work and looking forward to actually learning how to make games!

  • @walterh2113
    @walterh2113 2 роки тому +15

    Thanks for pointing out the mistake Peonso!

  • @joshuamorris1851
    @joshuamorris1851 2 роки тому +8

    Found this channel today while looking up state machines. I love how clear the explanations are. Kudos!

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

    Can’t wait for the next video and thanks Penonso!

  • @drax5.6.78
    @drax5.6.78 2 роки тому +2

    Too excited for your videos always keep up your good work

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

    I want to thank you for your great videos, which obviously you spend time a lot to make them. They help me a lot.
    I definitely donate these videos. Thanks

  • @AlexBlackfrost
    @AlexBlackfrost 2 роки тому +6

    Damn, I totally missed this when I watched the video. Thanks Peonso for pointing it out! And thanks Nicky for making an entire video to explain this and not just a pinned comment👍.

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

      I thought about it... And was originally going to just include this in the refactor for state machines, but I thought the topic was actually worthy of its own video!

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

      @@iHeartGameDev Good idea. By the way, I think it would be nice to add a card linking to this video on the velocity verlet integration section of the jump video.

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

      @@AlexBlackfrost that is a great idea!! Thanks Alex!

  • @ThinganatorX
    @ThinganatorX 2 роки тому +18

    Another awesome tutorial, and the fact that you were willing to make another video showing the mistake in the code, and showing us how you fixed it was really awesome. Everybody makes mistakes, especially while coding, and knowing how to go back and fix those mistakes is what makes a developer .
    Question for you, I've been trying to implement camera referenced movement to this movement system, and having issues due to the way the movement is set up. How would I go about doing so? I can't seem to use the camera to transform any of the values without breaking the current movement. Any help would be greatly appreciated. (I noticed a few people were asking about this in the previous videos as well)
    Thank you for all the great content!

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

      Hey! Thanks so much! I haven’t actually tried with a camera yet. The next video in this series is going to be about state machines, but the one after that will be about cinemachine! Stay tuned 🙌
      Cheers 🍻
      -Nicky

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

    absolute champion! 🙌🏾

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

    Thanks Peonso!

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

    Awesome job!

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

    Awesome stuff

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

    I tried your first flawed Velvet Integration on movement, replacing my original Euler method "It's the first go to for any movement". And as you pointed out here, it was wrong and didn't work.
    Now you fixed it here, I implemented it and MMH it feels really good moving around.
    Been struggling finding a balance of drag and acceleration using the usual, applying acceleration to velocity directly. This worked really well, better than using a Lerp as friction/drag which was good as well.
    Was worried having to modify the original player script to add another velocity vector as I try to follow the open close principle. But I think the result was worth the change.

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

    Such a great channel.

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

      Thanks very much Logan! Appreciate you still watching!

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

    love this

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

    Man u are awesome

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

    Hey Nicky - love the videos thank you! I'm seeing my character slow down when he's jumping. How do I keep him moving at the same velocity he runs at throughout the jump?

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

    i would like to say that you as a gamedev, deserve too much money

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

    Very great tutorial. Make a video on Pun 2 multiplayer ❤💙❤

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

    Super awesome tutorial. And one of the best third person controllers, Ive ever seen. You are very good at explaining complex topics. :) I have a question. How would you tie this in to a follow camera system? What I mean, now, the movement directions are world based, and its fine, with static camera. So when I get a follow camera (for example Cinemachine third person cam), I need to plug camera's forward direction to movement vector? I also need to do something about the rotation as well?

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

      Hey! Thanks so much! I’m currently working on the first Cinemachine tutorial as we speak! It doesn’t answer your question but I know we will get there within the next few videos!

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

      @@iHeartGameDev Nice! I will be waiting for new videos! Keep on rockin!

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

      Hello,
      6 Months to late but did you solve this problem?

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

    At 6:12 I don't understand we change currentRunMo' by appliedMo' but leave currentMo' as it : does that mean we're not using the Veler calculation in a Walk scenario ?

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

      You might already have the answer to this, but I think it's because "appliedMovement" is now used everywhere for the actual movement, and "currentMovement" is just used for the calculation for "appliedMovement" instead.

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

    based on what you did which jumping is it safe to say that I can use a state machine to create a combo system?

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

    The best game dev channel!!

  • @4per8
    @4per8 Рік тому +1

    good tutorial, for some reason now when i release the jump button it doesnt start falling immediatly so i had to improvise some extra code

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

    It jumps everytime the same high and it's independence from timeScale? Various jump high?

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

      Various jump heights was added in the previous video! And this video fixes the Velocity Verlet integration that was started last episode!

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

    How can i loop in 3 dimension?

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

    anyone else have the jump animation lock up if they're pressing the run button when they land? mine gets stuck

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

    Hey, I just applied the fix but now when Jammo is on Idle and jumps the animation plays several times, it looks like it's waving while jumping lmao. While jumping while walking or running works just fine. Plus before fixing all 3 situations worked fine. Mind I've not applied the 3 jump mechanic, only the jump once. Anyone might know what's wrong?
    I've got little programming knowledge so try it to explain it simple, please

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

    Is Velocity Verlet even needed if you use FixedUpdate instead of Update? My naive impression is that FixedUpdate exists to solve all potential physics framerate mismatches, or am I missing something?

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

      As far as I know yeah pretty much. Actually physics stuff shouldn't even be done in Update. Even Unreal and Godot have similar functions for that specific purpose. The physics engine runs on a fixed framerate and that's why fixed update functions exist. It allows you to only send one set of commands to the physics engine each physics frame, independant of the game's framerate ! Based on the GDC conference "Building a better jump", Velocity Verlet is still worth it for being somewhat simpler than the version of the Euler solution presented in said conference though.

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

    So in other words you were doing physics calculations outside of the physics step rate :p