How Jumps Work - Kinematic Character Controller in Unity

Controlling player jumps from and sticking to the ground
Try out the demo at nickmaltbie.com/OpenKCC
GitHub project at github.com/nicholas-maltbie
Open-Source Kinematic Character Controller Series Playlist - • Open-Source Kinematic ...
Project documentation - nickmaltbie.com/OpenKCC/docs
How a player jumps in a virtual environment is a more complex topic than I initially expected, and it has been a constant point of change and improvement in the OpenKCC Project throughout its development. I was even able to find and fix a few bugs in the character jump mechanics while making this video.
This project is fully open source and there is a simplified version of the Kinematic Character controller in the project called SimplifiedKCCWithJump.cs stored here github.com/nicholas-maltbie/O...
Chapters:
Intro 0:00
Character Controllers 0:22
What is a Jump 1:03
Types of Jumps 1:37
When can the Player Jump? 2:26
Sliding Down Slopes 3:12
Jumping Direction 3:56
Quality of Life Additions 4:44
Snapping Player Down 5:11
Future Additions 5:46
Code Example 6:03
Outro 6:36
Games in the order they first appear in the video:
* Super Mario Odyssey
* Pokémon: Brilliant Diamond
* Zelda: Breath of the Wild
* Celeste
* Overwatch
* Human: Fall Flat
* Besiege
* Minecraft
* Super Smash Bros. Ultimate
* Fall Guys: Ultimate Knockout
#gamedev #madewithunity #gamedesign

Пікірлер: 21

  • @user-wf2ov8yw7u
    @user-wf2ov8yw7u Жыл бұрын

    Great series of videos, really interesting to hear it all. I havn't had the opportunity to try the demo out but I'm wondering if this controller solves the issue of falling through floors at high speeds (i.e jumping off a cliff)? If so, what's the method used and how does it ensure such behaviour? thanks!

  • @pewpew518
    @pewpew5182 жыл бұрын

    In my implementation, character jumps in the direction of input at an angle. For example if the character is moving forward and player pushed joystick back the player will jump back wards however the angle will be 45 degrees upwards. This angle can be tuned. If there is no movement Inout player will jump straight up in place. I also have what I called "anticipation time" this isn't jump time but a part of jump. It's a small delay before jumping. This allows for the squat down part of jump to be completed on ground before jump and also allows for the player to rotate and face in input direction of the jump before jumping.

  • @NickMaltbie

    @NickMaltbie

    2 жыл бұрын

    That’s a neat idea to rotate jump in direction of motion. That’s at they jump farther when moving forward or whatever direction they decide. Anticipation time also seems interesting, it could allow for some error correction before jumping. I’ve seen this feature added for games where you would control a slow moving mech so taking extra time to correct a jump helped it feel like a very powerful jump with lots of animations and post processing. When testing out the jump feature with my friends we found that an instantaneous jump was the most natural flow so I’m curious what you used for this anticipation delay time. In our tests it felt more natural to jump the same frame you hit the jump button even if it skipped the jump animation and it felt easier to control. Although we were designing a multiplayer racing platformer game so precise inputs weren’t the main focus.

  • @pewpew518

    @pewpew518

    2 жыл бұрын

    @@NickMaltbie I think instantaneous jump makes perfect sense for say a platformer type game or a game in which you u need super responsive movement like overwatch. Also there's a big difference between our implementations . in your controller player always looks in the direction of the camera. In mine its a more typical third person controller where player moves relative to camera. also that jump anticipation is very small, few frames but it is slightly noticeable . If I'm not wrong I think ghost of tsushima does this, a slight anticipation before jump. I think this makes the jump more impactful and juicy. But again I'm making a open world RPG so I don't need instantaneous responsiveness for everything , I value the game feel more .

  • @NickMaltbie

    @NickMaltbie

    2 жыл бұрын

    Yes, I want to add the ability to move in a different direction than the camera (or at least have the player point in the direction they are moving). Adding that plus IK to the feet are two big things I want to add to improve the visuals. Each game has very different requirements and the idea that one piece of code could handle all use cases would lead to far too many parameters. I like sharing notes and code so hopefully the open source project will prove useful for someone’s future project and learning more about coding. Good luck on your project! I would love to see those sample jumps if you have any videos or demos, it sounds like an interesting scenario (although sometimes stuff is confidential during dev so no pressure to share if you aren’t able).

  • @jovlem
    @jovlem5 ай бұрын

    At 2:55 , how do you get the angle? Are you using the surface normal OR the normal from the collisionshape?

  • @whitesilver5575
    @whitesilver5575 Жыл бұрын

    This is an amazing series! I learned a lot from the previous videos in short amount of time. Anyway, Do you know the solution that will avoid the character controller from standing on top of another character? I see this in a lot of AAA titles but it seem impossible when i try to do it myself. The solutions i found on the internet doesn't seem to be the same approach as their solution says that i should get the ground normal and slide/bounce from there by changing the velocity, and it just doesn't feel tight if i try that approach. Thank you for sharing you knowledge with us!

  • @NickMaltbie

    @NickMaltbie

    Жыл бұрын

    Hi, that is actually a more complex requirement. I am designing a kinematic character controller that uses kinematic movement to avoid clipping and jittery movement that might come from a default rigidbody. Whenever the player is standing on a surface that is to "steep" or not on anything at all they start "sliding" down. I'm going to change to a state machine-based model and call this state sliding when they are standing on something but slipping down and unable to jump. I'm assuming this is the kind of behavior you would like to have from your character controller as well. In this case, I would label other character as a "sliding" or "no stand" surface where they will start accelerating downwards and sliding off the character that they are standing on. I have another video on Moving Characters in Games for how I achieve this for my Kinematic Character Controller design. I just updated the docs via PR #85 for the project github.com/nicholas-maltbie/OpenKCC/pull/85 If you have any questions let me know!

  • @whitesilver5575

    @whitesilver5575

    Жыл бұрын

    @@NickMaltbie the effect i wanted to happen were the same as the one in fighting games when they try to jump over especially when on a corner, they never stand on top. their sliding also never break the fall, they fall like there were never a character below them. i think I'll somehow get a similar result if i try to project the character's collider like on your previous video. thanks for responding!

  • @NeatGames
    @NeatGames2 жыл бұрын

    Very interesting! I'm using a 3rd Person character asset from the Unity store in my current project. I can't code all this haha

  • @NickMaltbie

    @NickMaltbie

    2 жыл бұрын

    Using assets from the store is a perfectly reasonable solution. It still takes quite a bit of skill to use someone else’s project and get it working in your use case. I have a simplified demo of the KCC movement linked in the video description if you’re interested in how the code works. And the full version as well, but that code is a bit more complex. I’ve been working on this project for a bit over two years and still keep finding and fixing basic bugs as I add and adjust features so maybe spending some money on a store bought asset would have been the easier solution. Good luck on your project!

  • @Patricebrouh
    @PatricebrouhАй бұрын

    Hi! In the vodeo, when Mario jumps, the camera doesn't follow him. Can you show me how to implement it? Thanks

  • @NickMaltbie

    @NickMaltbie

    Ай бұрын

    It’s called vertical damping. Unity has a standard implementation of it in their cinemachine package. It’s used in lots of games to make camera motion smoother.

  • @Patricebrouh

    @Patricebrouh

    Ай бұрын

    @@NickMaltbie Thank you

  • @pierrethehandsome2518
    @pierrethehandsome25182 жыл бұрын

    Is there a way to disable or minimize air movement in your particular project?

  • @NickMaltbie

    @NickMaltbie

    2 жыл бұрын

    Yes actually, in the GetProjectedMovement function I compute the player speed using the "isSprinting" state. Instead of using just the isSprinting state, you could add another check for (OnGround) and if (OnGround) is false, you could decrease the player's movement speed. Vector3 movement = RotatedMovement(inputMovement) * (isSprinting ? sprintSpeed : walkingSpeed); github.com/nicholas-maltbie/OpenKCC/blob/aaee7058baf33e6f4532e115cc4cbb7c1b6dff2b/Assets/OpenKCC/Scripts/Character/KinematicCharacterController.cs#L821 I also saw that you left a comment earlier about not being able to download the files but didn't get chance to respond. Make sure to download the git-lfs assets :)

  • @pierrethehandsome2518

    @pierrethehandsome2518

    2 жыл бұрын

    @@NickMaltbie Thank you for the advice! yes I had an issue with the download earlier, but it was just me being stupid lol

  • @NickMaltbie

    @NickMaltbie

    2 жыл бұрын

    @@pierrethehandsome2518 Great, I hope the adjustment works for your use case. I'm going to try and update it to a FSM based design so it will be more modular in the future and easier to edit values like movement speed in different states (such as falling). Git-LFS can be tricky, not a stupid mistake at all. It took me quite a few attempts to get it right and even longer to get it working in the CI/CD pipeline for my project. Good luck on your project, I'd love to hear any updates or examples of people using the OpenKCC project. I'm happy to help out with hwo to use the projects as I continue to document, make videos, and add more features.

  • @watercat1248
    @watercat1248 Жыл бұрын

    In my game the player able to move in the air with the same speed ground and the have air jump as well (double jump) However the ground check need important for sure Wail my game it's fps I have multiplayer I have plan to to add some platforming action in my game Like for example one way floor bunch pad ECT But I have not figured out how to add one way floor that doesn't have enge issues in 3D collider

  • @moon..9852
    @moon..9852 Жыл бұрын

    how can i use the kcc with my animation >> help pls

  • @NickMaltbie

    @NickMaltbie

    Жыл бұрын

    Hi, what’s your question with adding the animation to the KCC? There are some examples in the GitHub repo as well.