How Jumps Work - Kinematic Character Controller in Unity

  Рет қаралды 12,966

Nick Maltbie

Nick Maltbie

Күн бұрын

Пікірлер: 24
@pewpew518
@pewpew518 2 жыл бұрын
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).
@dec_ves2190
@dec_ves2190 5 ай бұрын
I do have a question, how can i add air control in this? Most games allow you to move in the air with limitations like not being able to move in the air instantaneously and also using a and d keys to strafe. Is there any way to add them?
@NickMaltbie
@NickMaltbie 4 ай бұрын
Yes, lots of existing character controllers have a “IsGrounded” or equivalent property. You can add a check when you apply player input to limit or modify player movement based on this property.
@jovlem
@jovlem 11 ай бұрын
At 2:55 , how do you get the angle? Are you using the surface normal OR the normal from the collisionshape?
@Patricebrouh
@Patricebrouh 7 ай бұрын
Hi! In the vodeo, when Mario jumps, the camera doesn't follow him. Can you show me how to implement it? Thanks
@NickMaltbie
@NickMaltbie 7 ай бұрын
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 7 ай бұрын
@@NickMaltbie Thank you
@RichardHao-x8y
@RichardHao-x8y Жыл бұрын
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!
@pierrethehandsome2518
@pierrethehandsome2518 2 жыл бұрын
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 2 жыл бұрын
how can i use the kcc with my animation >> help pls
@NickMaltbie
@NickMaltbie 2 жыл бұрын
Hi, what’s your question with adding the animation to the KCC? There are some examples in the GitHub repo as well.
@whitesilver5575
@whitesilver5575 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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
@NeatGames 2 жыл бұрын
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!
@Pravda-bw3tj
@Pravda-bw3tj 5 ай бұрын
ur controller shit what a state machine... with attributes.
Why Stairs Suck in Games... and why they don't have to
11:24
Nick Maltbie
Рет қаралды 1,5 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 135 МЛН
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 7 МЛН
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 54 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 2,5 МЛН
Explaining The Physics Behind Character Controllers - OpenKCC
6:56
How to Move Characters In Unity 3D | Character Controllers Explained
9:46
THIRD PERSON MOVEMENT in Unity
21:05
Brackeys
Рет қаралды 1,5 МЛН
Camera-Relative Movement in Unity 3D Explained
18:50
iHeartGameDev
Рет қаралды 46 М.
How Multiplayer Games Work
15:14
Nick Maltbie
Рет қаралды 244 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,2 МЛН
Improve your Platformer’s Jump (and Wall Jump) | Unity
8:12
Dawnosaur
Рет қаралды 127 М.
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 135 МЛН