A masterpiece, Nicky. The production quality, the graphical visualisations, the pace of the coding sections, correctly refrencing the contributions of others, and the engaging voice work.
Perhaps you can help me Geoffrey, I have written the code exactly as it is shown, but I get compiler errors. The main one is this: Assets\Standard Assets\Characters\ThirdPersonCharacter\Prefabs\My Scripts\AnimationMotionController.cs(48,39): error CS1061: 'PlayerInput.CharacterControlsActions' does not contain a definition for 'Jump' and no accessible extension method 'Jump' accepting a first argument of type 'PlayerInput.CharacterControlsActions' could be found (are you missing a using directive or an assembly reference?) I am continuing from the other two parts in this tutorial series so everything is set up as it is supposed to be, since this video has helped you, can you please help me to find where my mistake is?
@@kingdom216 , as a guess, that error message suggests to me that you have not created an action called "Jump" in your input actions which you seem to have called CharacterControlsActions - you know, the place where you setup the input bindings, etc. Have you spelled it correctly?
I've been waiting so long for this video to come out that I start to think he must have thought: "nah, this series are too good to be free for the general public, from now on, it will be exclusive only to patreon supporters" Thank you for your work, time, effort and dedication to this videos, seriously.
i started making a 3d platformer prototype a while ago, while i managed to make simple movement and a simple double jump mechanic i couldn't get it quite the way i wanted it to be. excited for this video!
You really do have a gift of explaining things. The composition and detail of your videos really show how much thought and work you put into them. You probably deserve more than you get from it all, but I can guarantee you that people appreciate it and that your insight is inspiring. Thank you sir
Love these videos! For what it's worth, there is a small error in handleJump() (26:09 in the video). Lines 75 through 78 should be: float secondJumpGravity = (-2 * (maxJumpHeight * 1.5f)) / Mathf.Pow(timeToApex * 1.25f, 2); float secondJumpInitialJumpVelocity = (2 * maxJumpHeight * 1.5f) / (timeToApex * 1.25f); float thirdJumpGravity = (-2 * (maxJumpHeight * 2f)) / Mathf.Pow(timeToApex * 1.5f, 2); float thirdJumpInitialJumpVelocity = (2 * maxJumpHeight * 2f) / (timeToApex * 1.5f); Note that we are multiplying by 1.5 and 2.0 rather than adding 2 and 4. This only matters if maxJumpHeight is set to a value other than 4.
I know this comment is a year old now, but would you call this an error or a preference? I personally prefer the addition and not the multiplication for any value of maxJumpHeight
@@clintonmansfield6364 I personally consider this a bug because if you do addition the second and third jump are not proportional to the first jump. So for example if maxJumpHeight is 2, then the second jump will be double the regular jump, rather than 1.5 times. Likewise if maxJumpHeight is 8, then the second jump would only be 25% of the initial height. I think this would be confusing if you tried to reuse this code and needed a different maxJumpHeight.
I have watched a lot of tutorial stuff over the years (including Udemy) and this channel is by far the best content I have come across. Going to check out the patreon!
We are all definitely not in the same space 2yrs later. This is still gold though. I think I have about all of Nicky's videos in some kind of referenced playlist. Right now, im making a jump mechanic that i hope to be as flexible as possible. Im just starting my gamedev journey but I'm an oldschool c/c++ and even some c# coder.. I guess we'll see what the future holds. Im excited and here for itmm hopefully the world doesn't go WWIII before I make my first game.
Aaah yes thank you for this video! This is the first time I've seen the state machine animation block and I'm blown away, I wish I discovered it sooner. This approach to jump is really useful and you can easily modify it to work with rigid bodies. Very cool
Thank you so much, Nicky. Your content is saved my time. you're amazing at explaining full of meaning each code. Request for explain follow camera to character
Oh damn, your tutorials are just the best... As an animator myself, I'm really glad that you keep the channel a bit "animation-heavy", but your coding is just so well executed. Even though I usually already know most of the things you're talking about in your vids, I always watch every single one of them, because they are probably the best Unity-centric content available. You're doing a great job man, thank you very much! Also I was wondering if you considered telling us something about inverse kinematics? I mean, most of it is quite well covered (at least quantitatively - there's quite a lot videos on that topic), but the tutorials are most often quite incomplete and not well done. There's surprisingly very little video material on well executed 2D runtime rigging, but I guess 2D is not your cup of tea. But any in depth tutorial on runtime rigging would be great! Cheers from Czech Republic, thank you for your vids, keep up the great work and have a great day!
Wow what a fantastic comment! Thank you so much for watching and for the kindness 😊 Regarding IK: I actually haven’t really ever used it myself. I think I’ll be getting to it eventually as we cover more topics on the channel!
Wow, I started the serie just to get a refresh on character controllers but damn yours is getting good and so simple to understand so we can mod it that I'm just going on Patreon to get access to the file! Awesome job! Keep going!
I've been looking everywhere for a proper analysis and implementation of Mario's jump. Not a Unity developer, but the production quality, explanations, and results are so good that I am considering attempting to apply the logic to Unreal.
The biggest problem in jumping is to be able to sync the animation with the actual jump. You chosed some settings on animations without any explaination of why you did that or what that mean(like set the root transform position etc). Judging on your previous videos I was expecting more. Anyway, keep up the good work.
Hey - thanks for watching! I tried my best here to replicate Mario’s instantaneous transition and stated why we were modifying the transition duration to allow the animations to blend better. There should be bits of explanation for most everything incorporated in the video, including why we were modifying animation transitions.
For me the static poses weren't working for me, because the timing was a little off, but i replace them with some actual animations and it was a whole lot smoother and the timing was way better, i guess you could try that instead. :)
I'm curious and also stuck, how can I make the character turn in the direction the camera is pointing while also keeping all the rotation code from before?
I've followed the tutorial until 12:42 minutes, but when I enter play mode, my character doesn't jump. Even though I've followed all the code. any suggestions for me? thank you, your tutorial is very good (sorry if my english is bad)
Same here, I reckon that the issue lies in the fact that we never use the jump variables anywhere else. Being a total beginner in c#, I can't figure out where to put it too ^^'
Between the videos, he adds "* Time.deltaTime" into the handle gravity function. Mine wasnt working either till I added those, guess he accidently forgot to put it in the video to add it from the previous one
Very helpful, thanks. There is a correction though. When you land back on the ground, the y velocity is 0 and so is the acceleration. This is because you are no longer moving vertically. If your y velocity was nonzero, then you'd be moving vertically. If your y acceleration is nonzero, then your vertical velocity would be changing. Neither of these are true, so both y vel and acceleration are zero. Also, your Verlet integration isn't correct. You are effectively just doing Euler integration with half the acceleration you want and declared with the gravity variable. Simply put, Verlet integration yields v(t+dt)=v(t)+.5(a(t)+a(t+dt))dt, which in the case of constant acceleration like we have here, that is the same as Euler integration (because a(t)=a(t+dt)). You only want Verlet integration if you have non-constant acceleration. So just use Euler integration with gravity cut in half, if you like the effects of what your code did.
I know I'm a year late to this, by why use a pair of Dictionary. They're expensive to look up. Why not have used a single (float Velocity, float Gravity)[]? Where index 0 is the first jump, index 1 is the second, and so on?
1 Array for pairs would defeat the point of the array, but yeah I was slightly raging over him using a dictionary only to use integers as keys. That being said, hashtables this small are almost as fast as the array, it's just funny that he went through the trouble of hashing components only to use a dictionary where an array is obviously faster.
Hmmm, I think I might Patreon for a bit as I can't see how this is working. You're calling Move above gravity and jump which suggests the Y need to persist frame to frame but you're also setting the Y * Time.deltaTime and then when currentMovement is applied it gets multipled out again???
the gravity snaps the player into the ground and it cannot jump is there any fix for the gravity, i followed the tutorial before about the gravity and it was snapping player to the ground too. how am i gonna get it to jump if its snapping!
Hey Hermanator! Unfortunately that’s one of the few things I don’t cover. The video is my longest yet and adding in the particle effect would have added even more! Maybe that would be a great short video to make after though! I’ll include it in the next Patreon poll 🙌
Hi, I was wondering will you do a momentum based movements tutorial ? Like the Mario one we can see in odyssey, etc. Would be interesting to see it. Like how would you manage acceleration, deceleration in the air and on the ground 👍
Hi @iHeartGameDev! First of all, thanks for the amazing tutorials. I want to give some feedback on the jump button release: Wouldn't it be nice if we set a min jump height for the "jump button release"? If there's no min jump height, then when you spam the jump button rapidly there gives inconsistent jump arcs and that feels really bad. If you take Hollow Knight as an example, when you tap the jump button rapidly the character hops quickly but with the exact same jump height (which is the minimum jump arc/parabola/or time, depending on which implementation is used), so the arcs of the jump for the min jump are always constant. The last time I coded the min jump I did it by comparing 2 things in fixedUpdate: (1) Jump Button UP and (2) the current Y velocity is less than a threshold that you set (this threshold could be your "initialJumpVelocity" - "a small amount (for instance, minJumpVelocity = initialJumpVelocity * 0.9f)". If the initialJumpVelocity is 10, then the minJumpVelocity = 9). This ensures that at least the character is going to travel a minimum distance (the distance travelled from the initialJumpVel until it reaches the minJumpVelocity by deceleration) before falling back down. A drawback of this implementation is that is less intuitive to set up, because you have to test the values until you find the min distance travel that you like for your jump. My question is, given your current implementation, is there a better way to set this minimum Jump height that suits the rest of the Jump with the verlet integration? The one I suggested would do it (In fact, I tested with 60fps and with 800fps and the results are very consistent across framerates), but its consistency is similar to the euler approach, there are still a really tiny amount of error, not really noticeable for a normal jump. However, if you set the jumpHeight to a really large number, then the inconsistencies could be a bit more noticeable (still low though, but worth to be corrected).
Hey there! 🙂 I am in the middle of your video, currently testing the first Jump attempt and… Well for some reason, unlike you, the character isn’t jumping much (1cm in 0.01s) 😂 It’s seems like gravity is super strong etc, but I watched your code again and again and it’s similar.. any idea what it can be related too? I have cubes falling as expected, but for the character, even starting from the sky with no action, it lands at top speed.. Weird 😬 Nice videos I must admit, very clear and super interesting, even for advanced dev 🙂 Thanks
Wow just perfect, it works sooooooo well! Anyone know how to add air control while jumping? Is there a way to isolate the y velocity of the player rather than use current movement.y?
Error resolved! at 12:29, the original gravity function in handleGravity was changed without comment. The handleGravity function should look like this: void handleGravity() { if(characterController.isGrounded) {
currentMovement.y = groundedGravity; currentRunMovement.y = groundedGravity; } else { currentMovement.y += gravity * Time.deltaTime; currentRunMovement.y += gravity * Time.deltaTime; } } the += gravity * Time.deltaTime is essential to making the jump work properly!
@Sorcha Murray It gets thrown out and replaced later in the course, but I have a hard time focusing on making changes when where we're supposed to be isn't working. Glad it helped!
I watched the animation series and I am working to make cool jumps. I would like to know more than unity.physics. the code I am using is: Rb.velocity=velocity.y+float. It works fine but the problem is that I want my object to look heavy. But useGravity is a bool and API is not accessible. Plus due to zero air resistance mass doesn't make any change.
Hey Sufian! Thanks for watching the series on animation! Currently I’m not handling rigidbody physics. I think we’ll get there eventually though so stay tuned!
Gravity value is accessible in Project Settings > Physics (default is 9.81 like on Earth). It's a global setting, so you can't tune it for every object. For air friction (what makes objects look light or heavy) the rigidbody parameter to tune is Drag (and Angular Drag). Anyway, you shouldn't use default Gravity for a playable character, you should compute your own and apply it as a vertical acceleration when your character is not touching the ground.
Will u be making any animation tutorials? Like in blender how to animate instead of taking them from Mixomo for example animations like Jump, Run, Idle, Slide, Crouch and all that. Would be greatly appreciated
Bro i have a question why don't you write the gravity value to -9.8?? as i have seen other tutorials of jump mechanism they are just using -9.8 and it just confusing me ?? as i don't have much knowledge about physics. Hope so you get my point and sorry for any confusion made my me in advance
Hi, just amazing these character controller tutorials. I'm learning about game developing and programming and I loved your way of explaining. As I remember Mario doing the 3 jumps without pauses when touching the ground, I tried to apply the same concept in case the jump button is pressed as soon as you hit the ground execute the second jump by changing the if of "handleJump" to " if (characterController.isGrounded && isJumpPressed)" is there any problem I didn't notice when removing !isJumping? Thank you very much for the tutorial
This video is really informative. I'll definitely be able to use some of this stuff for a kinematic Rigidbody character controller. Just need to convert from the CharacterController, I've wasted so much time on. Try doing jump-through platforms, without turning off the platform's collider. Spoilers. You'd think using the collider.isTrigger = true; function of CharacterControllers would do it. It doesn't. CharacterController controller; controller.detectCollisions = false; Doesn't actually do anything. I'm in 2019.4.29f1, so ymmv in the 2020 version, but it simply doesn't actually do anything in my version.
I'm having the same issue. Were you able to fix this? It seems as if somehow gravity must not be applied to the jump to slow him, but I'm not certain if that's the case. I'm not getting any errors , but jumping just takes me out of the screen.
@@Blueskies2513 That's unfortunate. I've managed to isolate the issue to the verlet implementation. The character jumps fine before adding in the "previousYVelocity" coding, but after, zoom through the roof. Not sure what in that code is causing it. I may end up going with another controller, or being happy enough with the simpler version of the jump for the time being with my time constraints.
@@Blueskies2513 I solved the issue. It's a small detail in the video, but when resolving the string of "previousYVelocity" variables, the final set needs to be changed to "=" and not "+=". It's a small detail, but it makes a huge different. He does say that in the video, but it's easy to miss.
Amazing. Is it easier to just have a blend tree for idle, walk, and run to simplify the transitions/have only one movement logic for the character controller, or does this not work properly?
Great tutorial thanks for posting. I have a question, currently the character stays in the jump animation the entire jump. How do you impliment a falling animation once the character reaches the apex of the jump?.
Thanks! There is logic already in the script that incorporates checking if the character is falling. Seems like a solid spot to switch the animation too!
I've encountered a problem after finishing all the areas until 19:00, when pressing jump my player gets yeeted, so to make small jumps i need to lightly and quickly tap the jump button, any idea how I can fix this? I've gone through the code 3 times and it's all the same.
Nevermind, my solution was that float previousYvelocity = currentMovement.y; float newYvelocity = currentMovement.y + (gravity * Time.deltaTime); float nextYVelocity = (previousYvelocity + newYvelocity) * 0.5f; currentMovement.y = nextYVelocity; it was currentMovement.y += nextYVelocity; before and now i removed the plus and its fine.
@@JahidulIslam-ev1zo Just saw your reply, and it worked for me, although I had to change the 'currentRunMovement.y += nextYVelocity to currentRunMovement.y = nextYVelocity as well, as the same problem would occur when running and jumping at the same time
Awesome tutorial! i've come upon an issue that when I do my second or third jump without moving the animation becomes weird. While I move it works perfectly though. Do you know how to fix this?
I have an issue where when I am running then jump, when my character lands, and I am still holding the shift key and a direction key, the jump animation continues to play indefinitely. Changing any input I am pressing will work fine and animate properly.
@@symmetrythomas7376 Hi, sorry but then I realized that i needed a different character controller, and from this video I kept only the handle gravity for the progressive jump.
I know it may seem a bit long from your question, but I solved this today. In the transition from Jump to Run you have to turn both conditions - isWalking and isRunning to true, because technically, when you hold your movement keys and your run keys, both of them are set to true :)
I have these errors: - PlayerInput.CharacterControls.Jump.started += onJump; error CS0120: An object reference is required for the non-static field, method, or property 'PlayerInput.CharacterControls' - PlayerInput.CharacterControls.Jump.canceled += onJump; error CS0120: An object reference is required for the non-static field, method, or property 'PlayerInput.CharacterControls' - currentRunMovement = nextYVelocity; error CS0029: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3' How do I fix them
How do we prevent our character from falling through the ground in the jump Router? My character falls through the ground when it is in the jump Router because there are no animation. Should we have something to prevent falling?
so turned out it was my raycast for my ground detection causing it - no idea how to fix it so gave in and used the character controller isgrounded instead -__-
This is so great! I do have some questions: Why do we need to calculate the gravity again if we already set it to a number? Is it to make the controls feel better? (Is that explained in the talk you referred to?) And why is the Jump/Falling still frame dependent if we are multiplying it by Time.deltaTime?
A masterpiece, Nicky. The production quality, the graphical visualisations, the pace of the coding sections, correctly refrencing the contributions of others, and the engaging voice work.
Thank you for such a kind comment, Geoffrey! The kindness means a lot! I hope the video helps you too!
@@iHeartGameDev we need more like these bro
Perhaps you can help me Geoffrey, I have written the code exactly as it is shown, but I get compiler errors. The main one is this: Assets\Standard Assets\Characters\ThirdPersonCharacter\Prefabs\My Scripts\AnimationMotionController.cs(48,39): error CS1061: 'PlayerInput.CharacterControlsActions' does not contain a definition for 'Jump' and no accessible extension method 'Jump' accepting a first argument of type 'PlayerInput.CharacterControlsActions' could be found (are you missing a using directive or an assembly reference?)
I am continuing from the other two parts in this tutorial series so everything is set up as it is supposed to be, since this video has helped you, can you please help me to find where my mistake is?
@@kingdom216 Start this video from scratch again, you missed some step or have a typo somewhere for sure.
@@kingdom216 , as a guess, that error message suggests to me that you have not created an action called "Jump" in your input actions which you seem to have called CharacterControlsActions - you know, the place where you setup the input bindings, etc. Have you spelled it correctly?
I can believe this content is free. Thank you;
This is like the only 3d Platformer Tutorial that made a professional looking result that I could find. Excellent job!
I've been waiting so long for this video to come out that I start to think he must have thought: "nah, this series are too good to be free for the general public, from now on, it will be exclusive only to patreon supporters"
Thank you for your work, time, effort and dedication to this videos, seriously.
Man, your teaching style is the best I've watched on the internet so far.
Thank you Marc :) happy to hear that you like it
i started making a 3d platformer prototype a while ago, while i managed to make simple movement and a simple double jump mechanic i couldn't get it quite the way i wanted it to be. excited for this video!
You really do have a gift of explaining things. The composition and detail of your videos really show how much thought and work you put into them. You probably deserve more than you get from it all, but I can guarantee you that people appreciate it and that your insight is inspiring. Thank you sir
The best tutorial I've seen yet since Brackeys. Tysm
I can't wait for the dynamic rigidbody character controller series!
Loved it! You did a pretty good job explaining complex topics like Verlet vs Euler in such a way that it is easy to understand.
You. Are. A GOD!!! Just subscribed and I'm now going to binge watch all your content. Best game development tutor hands down.
I nver see this quality in a channel i love this
Thanks very much!
Love these videos! For what it's worth, there is a small error in handleJump() (26:09 in the video). Lines 75 through 78 should be:
float secondJumpGravity = (-2 * (maxJumpHeight * 1.5f)) / Mathf.Pow(timeToApex * 1.25f, 2);
float secondJumpInitialJumpVelocity = (2 * maxJumpHeight * 1.5f) / (timeToApex * 1.25f);
float thirdJumpGravity = (-2 * (maxJumpHeight * 2f)) / Mathf.Pow(timeToApex * 1.5f, 2);
float thirdJumpInitialJumpVelocity = (2 * maxJumpHeight * 2f) / (timeToApex * 1.5f);
Note that we are multiplying by 1.5 and 2.0 rather than adding 2 and 4. This only matters if maxJumpHeight is set to a value other than 4.
I know this comment is a year old now, but would you call this an error or a preference? I personally prefer the addition and not the multiplication for any value of maxJumpHeight
@@clintonmansfield6364 I personally consider this a bug because if you do addition the second and third jump are not proportional to the first jump. So for example if maxJumpHeight is 2, then the second jump will be double the regular jump, rather than 1.5 times. Likewise if maxJumpHeight is 8, then the second jump would only be 25% of the initial height. I think this would be confusing if you tried to reuse this code and needed a different maxJumpHeight.
Thanks a bunch as this is really a great tutorial and I have to say it explains the concepts and implementation very succinct and precisely.
Thanks very much Dominik! I tried my best!
I have watched a lot of tutorial stuff over the years (including Udemy) and this channel is by far the best content I have come across. Going to check out the patreon!
I would like this video a thousand times if I could. thanks a lot man.
Another great video Nicky! Excited to see more!
Thank you Sig!! Hope all is well, buddy!
@@iHeartGameDev Aswell as one can be in these times! Hope you're doing better!
We are all definitely not in the same space 2yrs later. This is still gold though. I think I have about all of Nicky's videos in some kind of referenced playlist. Right now, im making a jump mechanic that i hope to be as flexible as possible. Im just starting my gamedev journey but I'm an oldschool c/c++ and even some c# coder.. I guess we'll see what the future holds. Im excited and here for itmm hopefully the world doesn't go WWIII before I make my first game.
While info in your videos is simply "really good", your editing level is over 9000. Thank you.
Great tutorial. Thanks :)
You could replace Mathf.Pow(timeToApex, 2) by timeToApex * timeToApex (line 67 at 11:30)
Pow is an expensive function.
Glad you liked it! And that is great to know! Thank you for sharing the knowledge!
Aaah yes thank you for this video! This is the first time I've seen the state machine animation block and I'm blown away, I wish I discovered it sooner. This approach to jump is really useful and you can easily modify it to work with rigid bodies. Very cool
Awesome Paulo! Happy to hear that it has already helped you 😊
my apologies for the year old comment. How do you convert this for rigid body instead of character controller?
This channel is gold! Thank you!!
thanks so much!
Thanks this was lifeline it made the jump look realistic and normal.
You have been sent by the codings gods! Thank you so so much I hope I can get to see more of your tutorials and hope to learn as much as possible!!!!
Incredible tutorial! Very easy to follow and with great instructions!
Huge thanks to you, Nicky!!!
This is a GREAT TUTORIAL
Thank you so much, Nicky. Your content is saved my time. you're amazing at explaining full of meaning each code. Request for explain follow camera to character
Oh damn, your tutorials are just the best... As an animator myself, I'm really glad that you keep the channel a bit "animation-heavy", but your coding is just so well executed. Even though I usually already know most of the things you're talking about in your vids, I always watch every single one of them, because they are probably the best Unity-centric content available. You're doing a great job man, thank you very much!
Also I was wondering if you considered telling us something about inverse kinematics? I mean, most of it is quite well covered (at least quantitatively - there's quite a lot videos on that topic), but the tutorials are most often quite incomplete and not well done. There's surprisingly very little video material on well executed 2D runtime rigging, but I guess 2D is not your cup of tea. But any in depth tutorial on runtime rigging would be great!
Cheers from Czech Republic, thank you for your vids, keep up the great work and have a great day!
Wow what a fantastic comment! Thank you so much for watching and for the kindness 😊
Regarding IK: I actually haven’t really ever used it myself. I think I’ll be getting to it eventually as we cover more topics on the channel!
Great job, Nicky! Keep it up!
Wow, I started the serie just to get a refresh on character controllers but damn yours is getting good and so simple to understand so we can mod it that I'm just going on Patreon to get access to the file! Awesome job! Keep going!
Awesome to hear, thank you! Please let me know if there’s any issues downloading the files 👍
I've been looking everywhere for a proper analysis and implementation of Mario's jump. Not a Unity developer, but the production quality, explanations, and results are so good that I am considering attempting to apply the logic to Unreal.
Hey thanks so much for the kindness!!
This is a great tutorial which has been really helpful to me. Thank you ☺
The biggest problem in jumping is to be able to sync the animation with the actual jump. You chosed some settings on animations without any explaination of why you did that or what that mean(like set the root transform position etc). Judging on your previous videos I was expecting more. Anyway, keep up the good work.
Hey - thanks for watching! I tried my best here to replicate Mario’s instantaneous transition and stated why we were modifying the transition duration to allow the animations to blend better. There should be bits of explanation for most everything incorporated in the video, including why we were modifying animation transitions.
For me the static poses weren't working for me, because the timing was a little off, but i replace them with some actual animations and it was a whole lot smoother and the timing was way better, i guess you could try that instead. :)
love this channel contents,
very very helpful tutorials.
Many Thanks
I love this video, and I really think most of your vids deserve more views! Amazing anaylsis/breakdown!
Love the series awesome job! Looking forward to the the next series!
Deserves more subs
Thank you
Thank you Mr.Nicky!!
This was very helpful!
WAITING!!
🙂🙂Wonderfully explained Nicky great work... Keep it up..
Thank you for the kindness Odinnie! Great to see familiar faces around here :)
@@iHeartGameDev ☺️☺️☺️ I see... You remembered me...
@@iHeartGameDev I honestly never thought youtubers would remember the persons who comment on their videos...
I can’t speak for everyone, but I try to!
@@iHeartGameDev thats great.. I actually like that about you
I used the clearly-presented info in this video to clean up messes I made following other tutorials :D
I always love your tutorial XD
Thank you!!! I hope it helps!!
Excellent ! thank you very much !!
This guy is the new Brackeys but better
Thank you for such a kind comparison!
Me who dosent know how to code and dosent understand any unity tutorials: cool 👍
I'm curious and also stuck, how can I make the character turn in the direction the camera is pointing while also keeping all the rotation code from before?
Thanks!
Amazing.
Mind blowing explanation. Greatest ❤💙❤ .Make a video on Pun 2 multiplayer ❤💙❤
I've followed the tutorial until 12:42 minutes, but when I enter play mode, my character doesn't jump. Even though I've followed all the code. any suggestions for me? thank you, your tutorial is very good (sorry if my english is bad)
Same here, I reckon that the issue lies in the fact that we never use the jump variables anywhere else. Being a total beginner in c#, I can't figure out where to put it too ^^'
had the same problem, just follow until 16:28
any other solution i followed the video but nothing happens
Edit: i fk up in the variables and my velocity was negative thats was my problem xD
Between the videos, he adds "* Time.deltaTime" into the handle gravity function. Mine wasnt working either till I added those, guess he accidently forgot to put it in the video to add it from the previous one
thank you
Isn't an Array faster than a Dictioinary?
Loving these tutorials, any chance we can get one on adding a camera to the player using cinemachine?
Very helpful, thanks. There is a correction though. When you land back on the ground, the y velocity is 0 and so is the acceleration. This is because you are no longer moving vertically. If your y velocity was nonzero, then you'd be moving vertically. If your y acceleration is nonzero, then your vertical velocity would be changing. Neither of these are true, so both y vel and acceleration are zero.
Also, your Verlet integration isn't correct. You are effectively just doing Euler integration with half the acceleration you want and declared with the gravity variable. Simply put, Verlet integration yields v(t+dt)=v(t)+.5(a(t)+a(t+dt))dt, which in the case of constant acceleration like we have here, that is the same as Euler integration (because a(t)=a(t+dt)). You only want Verlet integration if you have non-constant acceleration. So just use Euler integration with gravity cut in half, if you like the effects of what your code did.
I know I'm a year late to this, by why use a pair of Dictionary. They're expensive to look up.
Why not have used a single (float Velocity, float Gravity)[]? Where index 0 is the first jump, index 1 is the second, and so on?
1 Array for pairs would defeat the point of the array, but yeah I was slightly raging over him using a dictionary only to use integers as keys.
That being said, hashtables this small are almost as fast as the array, it's just funny that he went through the trouble of hashing components only to use a dictionary where an array is obviously faster.
regarding the physics, there is a bit of a confusion between Acceleration and Velocity. But we get your point ;).
Hmmm, I think I might Patreon for a bit as I can't see how this is working. You're calling Move above gravity and jump which suggests the Y need to persist frame to frame but you're also setting the Y * Time.deltaTime and then when currentMovement is applied it gets multipled out again???
Can you please make one for melee combat! please!
the gravity snaps the player into the ground and it cannot jump is there any fix for the gravity, i followed the tutorial before about the gravity and it was snapping player to the ground too. how am i gonna get it to jump if its snapping!
try disabling "apply root motion" in the animator
Hello, could you please include the smoke particles trail that Mario has in this tutorial? It would be awesome and I would really appreciate it XD
Hey Hermanator! Unfortunately that’s one of the few things I don’t cover. The video is my longest yet and adding in the particle effect would have added even more! Maybe that would be a great short video to make after though! I’ll include it in the next Patreon poll 🙌
@@iHeartGameDev okay, thanks!
Came for the video game mechanic tutorial, stayed for the applied calculus lesson
Hi, I was wondering will you do a momentum based movements tutorial ? Like the Mario one we can see in odyssey, etc. Would be interesting to see it. Like how would you manage acceleration, deceleration in the air and on the ground 👍
Hi @iHeartGameDev! First of all, thanks for the amazing tutorials. I want to give some feedback on the jump button release: Wouldn't it be nice if we set a min jump height for the "jump button release"? If there's no min jump height, then when you spam the jump button rapidly there gives inconsistent jump arcs and that feels really bad. If you take Hollow Knight as an example, when you tap the jump button rapidly the character hops quickly but with the exact same jump height (which is the minimum jump arc/parabola/or time, depending on which implementation is used), so the arcs of the jump for the min jump are always constant.
The last time I coded the min jump I did it by comparing 2 things in fixedUpdate: (1) Jump Button UP and (2) the current Y velocity is less than a threshold that you set (this threshold could be your "initialJumpVelocity" - "a small amount (for instance, minJumpVelocity = initialJumpVelocity * 0.9f)". If the initialJumpVelocity is 10, then the minJumpVelocity = 9). This ensures that at least the character is going to travel a minimum distance (the distance travelled from the initialJumpVel until it reaches the minJumpVelocity by deceleration) before falling back down. A drawback of this implementation is that is less intuitive to set up, because you have to test the values until you find the min distance travel that you like for your jump.
My question is, given your current implementation, is there a better way to set this minimum Jump height that suits the rest of the Jump with the verlet integration? The one I suggested would do it (In fact, I tested with 60fps and with 800fps and the results are very consistent across framerates), but its consistency is similar to the euler approach, there are still a really tiny amount of error, not really noticeable for a normal jump. However, if you set the jumpHeight to a really large number, then the inconsistencies could be a bit more noticeable (still low though, but worth to be corrected).
Hey there! 🙂
I am in the middle of your video, currently testing the first Jump attempt and… Well for some reason, unlike you, the character isn’t jumping much (1cm in 0.01s) 😂
It’s seems like gravity is super strong etc, but I watched your code again and again and it’s similar.. any idea what it can be related too?
I have cubes falling as expected, but for the character, even starting from the sky with no action, it lands at top speed..
Weird 😬
Nice videos I must admit, very clear and super interesting, even for advanced dev 🙂
Thanks
Great work ,do you kown why no video in mix and jam for long time
Thank you! I'm not sure about Mix And Jam. But André's videos are some of my favorites as well!
Awesome tutorial! Can we do camera controls next?
Maybe the next video will be about how to make a combat system?
Wow just perfect, it works sooooooo well! Anyone know how to add air control while jumping? Is there a way to isolate the y velocity of the player rather than use current movement.y?
you sure did put a lot of thought into jumping
Am I losing my mind or is anyone else getting a glitch where gravity sets itself to a random number and the jumps just DONT work?
Error resolved! at 12:29, the original gravity function in handleGravity was changed without comment. The handleGravity function should look like this:
void handleGravity()
{
if(characterController.isGrounded)
{
currentMovement.y = groundedGravity;
currentRunMovement.y = groundedGravity;
}
else
{
currentMovement.y += gravity * Time.deltaTime;
currentRunMovement.y += gravity * Time.deltaTime;
}
}
the += gravity * Time.deltaTime is essential to making the jump work properly!
@@joeymowery6124 Oh my gods thank you, I had no idea what I was doing wrong here.
@Sorcha Murray It gets thrown out and replaced later in the course, but I have a hard time focusing on making changes when where we're supposed to be isn't working. Glad it helped!
I watched the animation series and I am working to make cool jumps. I would like to know more than unity.physics. the code I am using is:
Rb.velocity=velocity.y+float.
It works fine but the problem is that I want my object to look heavy. But useGravity is a bool and API is not accessible. Plus due to zero air resistance mass doesn't make any change.
Hey Sufian! Thanks for watching the series on animation! Currently I’m not handling rigidbody physics. I think we’ll get there eventually though so stay tuned!
Gravity value is accessible in Project Settings > Physics (default is 9.81 like on Earth). It's a global setting, so you can't tune it for every object. For air friction (what makes objects look light or heavy) the rigidbody parameter to tune is Drag (and Angular Drag).
Anyway, you shouldn't use default Gravity for a playable character, you should compute your own and apply it as a vertical acceleration when your character is not touching the ground.
@@Bidule200 I am going with your answer thanks :)
@@iHeartGameDev After GDC, it looks like the case study of their theory. And man you just nailed it. Thanks to be here!
How to prevent steering during jump and continue after touching ground? Switch off steering and buffer input somehow.
Can You Make A double Jump move
Will u be making any animation tutorials? Like in blender how to animate instead of taking them from Mixomo for example animations like Jump, Run, Idle, Slide, Crouch and all that. Would be greatly appreciated
Bro i have a question why don't you write the gravity value to -9.8?? as i have seen other tutorials of jump mechanism they are just using -9.8 and it just confusing me ?? as i don't have much knowledge about physics.
Hope so you get my point and sorry for any confusion made my me in advance
10/10
ily
Ilyt
Hi, just amazing these character controller tutorials.
I'm learning about game developing and programming and I loved your way of explaining.
As I remember Mario doing the 3 jumps without pauses when touching the ground, I tried to apply the same concept in case the jump button is pressed as soon as you hit the ground execute the second jump by changing the if of "handleJump" to " if (characterController.isGrounded && isJumpPressed)" is there any problem I didn't notice when removing !isJumping?
Thank you very much for the tutorial
Hey! You are free to experiment and try out any changes and refractors you want! No big deal!
This video is really informative. I'll definitely be able to use some of this stuff for a kinematic Rigidbody character controller.
Just need to convert from the CharacterController, I've wasted so much time on.
Try doing jump-through platforms, without turning off the platform's collider.
Spoilers.
You'd think using the collider.isTrigger = true; function of CharacterControllers would do it.
It doesn't.
CharacterController controller;
controller.detectCollisions = false;
Doesn't actually do anything.
I'm in 2019.4.29f1, so ymmv in the 2020 version, but it simply doesn't actually do anything in my version.
if im using rigidbody is the same but rb.velocity = currentMovement ? thnx for this tutorial!!!
Nicky, please, i need your help! how can i do a ledge grab? i tried everything but nothing worked. You have a big fan from Brazil!
my character jumps so high that they just disappear in less than a second please help
I'm having the same issue. Were you able to fix this? It seems as if somehow gravity must not be applied to the jump to slow him, but I'm not certain if that's the case. I'm not getting any errors , but jumping just takes me out of the screen.
@@graytreegames6151I sadly couldn't fix it
@@Blueskies2513 That's unfortunate. I've managed to isolate the issue to the verlet implementation. The character jumps fine before adding in the "previousYVelocity" coding, but after, zoom through the roof. Not sure what in that code is causing it. I may end up going with another controller, or being happy enough with the simpler version of the jump for the time being with my time constraints.
@@Blueskies2513 I solved the issue. It's a small detail in the video, but when resolving the string of "previousYVelocity" variables, the final set needs to be changed to "=" and not "+=". It's a small detail, but it makes a huge different. He does say that in the video, but it's easy to miss.
@@graytreegames6151 oh wow, it aactuaoy woiied
Can u make GROUND POUND attack with character controller
Amazing. Is it easier to just have a blend tree for idle, walk, and run to simplify the transitions/have only one movement logic for the character controller, or does this not work properly?
Great tutorial thanks for posting. I have a question, currently the character stays in the jump animation the entire jump. How do you impliment a falling animation once the character reaches the apex of the jump?.
Thanks! There is logic already in the script that incorporates checking if the character is falling. Seems like a solid spot to switch the animation too!
Does anyone have an idea of how to make the 3rd jump stationary n not actually make you move??
try disabling "apply root motion" in the animator
I've encountered a problem after finishing all the areas until 19:00, when pressing jump my player gets yeeted, so to make small jumps i need to lightly and quickly tap the jump button, any idea how I can fix this? I've gone through the code 3 times and it's all the same.
I am having the same issue, have you found a solution?
Nevermind, my solution was that
float previousYvelocity = currentMovement.y;
float newYvelocity = currentMovement.y + (gravity * Time.deltaTime);
float nextYVelocity = (previousYvelocity + newYvelocity) * 0.5f;
currentMovement.y = nextYVelocity;
it was currentMovement.y += nextYVelocity; before and now i removed the plus and its fine.
@@JahidulIslam-ev1zo Just saw your reply, and it worked for me, although I had to change the 'currentRunMovement.y += nextYVelocity to currentRunMovement.y = nextYVelocity as well, as the same problem would occur when running and jumping at the same time
Awesome tutorial! i've come upon an issue that when I do my second or third jump without moving the animation becomes weird. While I move it works perfectly though. Do you know how to fix this?
Hello Nicky! Couls you please explain me why you modify the initialJumpVelocity at 16:14? Wouldn't it just work like it is?
I have an issue where when I am running then jump, when my character lands, and I am still holding the shift key and a direction key, the jump animation continues to play indefinitely. Changing any input I am pressing will work fine and animate properly.
same problem here, any solution? thanks
@@JackTransistor Any Luck??
@@symmetrythomas7376 Hi, sorry but then I realized that i needed a different character controller, and from this video I kept only the handle gravity for the progressive jump.
I know it may seem a bit long from your question, but I solved this today. In the transition from Jump to Run you have to turn both conditions - isWalking and isRunning to true, because technically, when you hold your movement keys and your run keys, both of them are set to true :)
@@stanisawksel4682 wow, this came in just in time for me lol. Thank god you decided to respond
is there a reason we don't just do the physics calculations (gravity) in fixedupdate?
I have these errors:
- PlayerInput.CharacterControls.Jump.started += onJump; error CS0120: An object reference is required for the non-static field, method, or property 'PlayerInput.CharacterControls'
- PlayerInput.CharacterControls.Jump.canceled += onJump; error CS0120: An object reference is required for the non-static field, method, or property 'PlayerInput.CharacterControls'
- currentRunMovement = nextYVelocity; error CS0029: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'
How do I fix them
I am getting different errors and it doesn't seem that there is anyone to address these issues.
It sounds like you haven’t set the reference to an instance of PlayerInput. If you haven’t watched the previous episode, you need to.
@@iHeartGameDev I resolved the problem.
Could you make a tutorial when you fix a rotative camera to this character (with right joystick)?
How would you apply this to knock back force using the character controller and Collision detection?? PLease help
How do we prevent our character from falling through the ground in the jump Router? My character falls through the ground when it is in the jump Router because there are no animation. Should we have something to prevent falling?
I am pretty sure someone has asked this but why didn't you use the "Any State" for the jump animation?
:) I didn't know how that works tbh
yeah... my jump just immediately zips to the peak, of which is a very small jump. it's not calculating per frame on the way up, only way down -__-
so turned out it was my raycast for my ground detection causing it - no idea how to fix it so gave in and used the character controller isgrounded instead -__-
Hello I love your videos but for some reason if I hold dow the jump button my character keeps jumping. Is there anyway to stop it
Hey is there a way to change the handleRotation method to rotate with the mouse instead of the WASD keys?
This is so great!
I do have some questions:
Why do we need to calculate the gravity again if we already set it to a number? Is it to make the controls feel better? (Is that explained in the talk you referred to?)
And why is the Jump/Falling still frame dependent if we are multiplying it by Time.deltaTime?
I had this question but then I realized the answer. He isn't moving the character to jump, he's manipulating the gravity.