Great lesson, you explain it very clearly, and you even have work around for a problem that we wouldn't need to address. Congratulations and thank you!
Yours so far is the only tutorial I could get the scripts to align with my current code properly with the new input system. I just compared the code left on your dotnetfiddle thing but you should post your name on it or something as I actually had a hard time finding the tutorial again after I clicked on the link. Deserve a like and follow though as I've gone through hours and hours of tutorials always hitting a wall where everyone seems to hit, and this actually moved me forward with character inputs. Thanks so much for the amazing information.
Thank you for this! I recently started using the CharacterController to manage movement and that isGrounded glitch was driving me crazy! You've earned my subscription Ketra; thank you.
Really love your lessons, thanks a lot for them. I just had more problems with the ySpeed issue. I'm using different character and initialy had to make it -1 in order to make it stop moving all the time. When I added the idle animation, it broke completely and started moving again all the time. I did some googling and found out a solution that works for me so far, I had to change "Min Move Distance" in "Character Controller" to 0 and this solves the issue for me, can even have the ySpeed = 0 now. Hope this won't cause any new issues thought.
Thanks for sharing your solution. Changing the Min Move Distance to zero will be fine in most scenarios. This is taken from the Unity documentation "If the character tries to move less than this distance, it will not move at all. This can be used to reduce jitter. In most situations this value should be left at 0." We're planning to do a refresh of these tutorials at some point so will probably change to this solution at that point 😊
Amazing video. Your voice is really nice and easy to understand, plus you cover way more than I expected (aka stuff I'd need to spend time googling otherwise). Well done, thank you for this :)
Excellent tutorial, short and well explained. Did you considered calculate the Y velocity based on a desired jump height? I think is also important to know how height are character will get. In that scenario is used the formula Y VELOCITY = square root ( JUMP HEIGHT * -2 * GRAVITY )
Hi, thanks for this. To change the gravity you can change it in Edit->Project Settings->Physics. Or you could add a gravity multiplier field in the script. Something like [SerializeField] private float gravityMultiplier; ... Physics.gravity * gravityMultiplier ... That way you can change the gravity multiplier in the Inspector for the character without affecting the gravity of other objects. Hope that helps 😊
Hi nice tutorial. I would suggest to have a change to have a option to set player's gravity independently rather than changing phyics.gravity which will affect all other phyics objects.
The main issue I've found with CharacterController's ground-detection is that it often doesn't work unless you're on totally-level terrain. Any chance you can make a tutorial to address that?
Amazing tutorial! One question: How do I make this work on a mobile phone with Input Get Touch? I tried to add the touch phase but I cannot jump and move the player, it only moves at a slow speed.
Hi, you could try changing the Min Move Distance on the Character Controller to zero in the Inspector. Hopefully this will stop the fluctuating speed 😊
Any tip on how I can get the quick action or lightbulb to pop up? I can't introduce a local variable because I don't see either one of those there to let me do it. Any help would be greatly aprpreciated.
Hi, what code editor are you using? The lightbulb should be there in Visual Studio 2019. If you can't get it to work, you can still make the changes manually to continue with the tutorial - it will just take a little longer 😊
Hello! , is the issue about the isGrounded flag and Step offset obsolete with the newer versions of unity? I dont seem to run into the same issues that you have had in this video, if anything its working fine.
@@KetraGames I think it's fixed now. I'm using 2021.3.6f1 and when I set the ySpeed to 0f it doesn't fluctuate. If I have it at 0.5f my player bounces up and down, slightly, when it's on the ground
got it too work. for some reason my character doesnt want to jump when going diagnollly. when i hold either left+down or up+right, he can jump. when i hold either left+up or right+down, he cant jump. for now ill leave this aside since i can jump then move diagnolly. any possible reason why this might happen?
Hi, there are two ways you could do this. First you could increase the gravity in the physics settings. Editor -> Project Settings -> Physics Alternatively, you could add a gravity multiplier in the script. So where we apply the gravity would look something like this ySpeed += Physics.gravity.y * gravityMultiplier * Time.deltaTime; Then you could set the gravityMultiplier to 1.5 for example to increase the gravity applied. Hope that helps 😊
@@KetraGames While your suggestion is good, why not just do something like (start of script) public float gravity = ; (gravity logic) ySpeed += gravity * Time.deltaTime; Is there a reason to use Unity's prebuilt gravity? Maybe NPCs are using rigidbodies, so it's easier to adjust their gravity later on without having to then go back to adjust the player's multiplier. Am I just pointing out useless solutions, or is there a reason to do it your way that I'm missing?
@@washurpaws Hi, either way would work, but using the Unity gravity value is a useful global setting that can be used so that all objects in the game are using the same value for gravity. Having a multiplier then allows different objects to fall faster or slower than this value as desired
my character still jumps continuously if i press the space bar. The isGrounded doesnt seem to be working. Am i right in thinking isGrounded isnt set as private bool
does this jump code work with rigidbody character controllers? for some reason the ySpeed value does not stop decreasing and my character doesnt touch the ground to trigger the isGrounded bool
Hi, the lightbulb helps you refactor code quickly but if you don't have it you can type the changes manually and get the same result. Hope that helps 😊
Hi, what you could do is replace the key check with a check on a boolean field. So instead of if (Input.GetButtonDown("Jump")) {...} you could do if (jumpButtonPressed) { ... jumpButtonPressed = false; } You would then need to wire up the button click event to a method that sets this field to true. We're planning to do some tutorials on mobile controls in the future but hope this helps in the meantime.
If I want to add force to the Y axis of an object ignoring the environment Y axis , Because the object mute flip and I don't want to push it it from the back. what should I write?
Hi, sorry I don't fully understand the question. If you are adding force to a Rigidbody and you don't want it to flip then you can lock the rotation on any axis. Hope that helps
Hey, I've been wanting to create an auto-jump mechanic like the one from Ocarina of time, I've watched tons of movement/ jump tutorials, searched on forums and haven't found anything close to it, could you make a tutorial on this? I'm a newbie and your videos have been really helpful, thanks.
Hi, that sounds like an interesting challenge. We'll add it to the list of future videos. I think the way that you would go about this would be to cast a Ray down toward the ground just ahead of your character. If you detect that there is no longer any ground ahead of the character, then trigger the jump.
Hi, you could use the OnControllerColliderHit method to get more detail on what the character has collided with. Then you could check if it's in the ground layer to enable the jump. docs.unity3d.com/ScriptReference/ControllerColliderHit.html
Why does the character shift a little when the program starts? I noticed that the little red alien goes from 0 for Y to -0.0199 and my own test with a cube goes from 0 to 0.0800. Is there a way for it not to do that?
Hi, what you could do is replace the key check with a check on a boolean field. So instead of if (Input.GetButtonDown("Jump")) {...} you could do if (jumpButtonPressed) { ... jumpButtonPressed = false; } You would then need to wire up the button click event to a method that sets this field to true. We're planning to do some tutorials on mobile controls in the future but hope this helps in the meantime.
for some reason when i jump the player gets stuck in the air for a second then goes back down. It only happens when the player isnt moving its good when im moving
Hello please help me.. i followed every step and i am getting issue that my player is getting back to ground very slower like its get back on ground in slow motion how can i fix this please help ...
Hi, it sounds like the gravitational acceleration isn't working properly. Check the line where you add the gravity and check you have it like this ySpeed += Physics.gravity.y * Time.deltaTime; You can also find the complete script at dotnetfiddle.net/0GDAm3. Hope that helps
I'm not the original creator of the video, but how I would do it is maybe have a second variable for "has the player doublejumped"? If the player presses the jump button and is grounded, it does the ground logic, but if they are not grounded, Unity will see if the doublejump boolean is true or false. If it allows doublejumping, it does the jump logic again, and marks the doublejump as true. When you're grounded, the doublejump allowed flag is set to true for the next time you need to jump.
Sorry you didn't find this tutorial helpful. There are always multiple ways to solve a problem in software development so you can take concepts covered in the video and adapt them however you like.
Great lesson, you explain it very clearly, and you even have work around for a problem that we wouldn't need to address. Congratulations and thank you!
Great to hear this, thanks 😊
Yours so far is the only tutorial I could get the scripts to align with my current code properly with the new input system.
I just compared the code left on your dotnetfiddle thing but you should post your name on it or something as I actually had a hard time finding the tutorial again after I clicked on the link.
Deserve a like and follow though as I've gone through hours and hours of tutorials always hitting a wall where everyone seems to hit, and this actually moved me forward with character inputs.
Thanks so much for the amazing information.
Thank you for this! I recently started using the CharacterController to manage movement and that isGrounded glitch was driving me crazy! You've earned my subscription Ketra; thank you.
Great to hear. Thanks for this comment 😊
Really love your lessons, thanks a lot for them. I just had more problems with the ySpeed issue. I'm using different character and initialy had to make it -1 in order to make it stop moving all the time. When I added the idle animation, it broke completely and started moving again all the time. I did some googling and found out a solution that works for me so far, I had to change "Min Move Distance" in "Character Controller" to 0 and this solves the issue for me, can even have the ySpeed = 0 now. Hope this won't cause any new issues thought.
Thanks for sharing your solution. Changing the Min Move Distance to zero will be fine in most scenarios. This is taken from the Unity documentation
"If the character tries to move less than this distance, it will not move at all. This can be used to reduce jitter. In most situations this value should be left at 0."
We're planning to do a refresh of these tutorials at some point so will probably change to this solution at that point 😊
You are a lifesaver!
This is a good Tutorial series, got stuck for a bit because the Lightbulb wasn't appearing for me.
Great video, still helped me today.
Best videos, thank you !!
CharacterController Component > Min Move Distance = 0
Thanks for this comment 😊
Amazing video. Your voice is really nice and easy to understand, plus you cover way more than I expected (aka stuff I'd need to spend time googling otherwise). Well done, thank you for this :)
Great, thanks for this comment 😊
I don't know why but for the ySpeed I had to do -1f for it to work
Man what a good and solid tutorial, thank you so much
Great to hear. Thanks for this comment 😊
that's nice lesson! Thanks to your lesson , I can work very quickly
Glad it was useful 😊
Excellent tutorial, short and well explained. Did you considered calculate the Y velocity based on a desired jump height? I think is also important to know how height are character will get.
In that scenario is used the formula
Y VELOCITY = square root ( JUMP HEIGHT * -2 * GRAVITY )
Thanks for the suggestion. We're working on an animated jump tutorial at the moment so we'll probably look to incorporate the jump height into that 😊
If people are still have issues with the jump work around, try setting the "Min Move Distance" to zero.
Thanks for this. Good tip 😊
What min move distance? i dont see that anywhere in the script.
great understanding
Hey! This is a brilliant video but I just would like to ask how do you change the gravity
Hi, thanks for this. To change the gravity you can change it in Edit->Project Settings->Physics. Or you could add a gravity multiplier field in the script. Something like
[SerializeField]
private float gravityMultiplier;
...
Physics.gravity * gravityMultiplier
...
That way you can change the gravity multiplier in the Inspector for the character without affecting the gravity of other objects.
Hope that helps 😊
Hi nice tutorial. I would suggest to have a change to have a option to set player's gravity independently rather than changing phyics.gravity which will affect all other phyics objects.
Thanks. Yes, you're right. Having a gravity parameter would be useful if you wanted the character to fall at a different rate.
The main issue I've found with CharacterController's ground-detection is that it often doesn't work unless you're on totally-level terrain. Any chance you can make a tutorial to address that?
Wow! Great! Thank you for this AMAZING tutorial, perfect for the begginers :). Now I understend more!
Thanks for this great comment 😊
Worked perfectly!
Great to hear this 😊
Amazing tutorial! One question: How do I make this work on a mobile phone with Input Get Touch? I tried to add the touch phase but I cannot jump and move the player, it only moves at a slow speed.
Feeling kind stupid but I can't find what I missed, the character ySpeed still keeps fluctuating while standing still and when moving its stable
Hi, you could try changing the Min Move Distance on the Character Controller to zero in the Inspector. Hopefully this will stop the fluctuating speed 😊
@@KetraGames Got same issue, your solution works perfectly well. Thanks and keep going this that great job !
Thank you!
👍😊
Any tip on how I can get the quick action or lightbulb to pop up? I can't introduce a local variable because I don't see either one of those there to let me do it. Any help would be greatly aprpreciated.
Hi, what code editor are you using? The lightbulb should be there in Visual Studio 2019.
If you can't get it to work, you can still make the changes manually to continue with the tutorial - it will just take a little longer 😊
Hello! , is the issue about the isGrounded flag and Step offset obsolete with the newer versions of unity?
I dont seem to run into the same issues that you have had in this video, if anything its working fine.
Hi, it may be that these issues are now fixed. I'll have to go back and check. Thanks for raising 😊
@@KetraGames I think it's fixed now. I'm using 2021.3.6f1 and when I set the ySpeed to 0f it doesn't fluctuate. If I have it at 0.5f my player bounces up and down, slightly, when it's on the ground
got it too work. for some reason my character doesnt want to jump when going diagnollly.
when i hold either left+down or up+right, he can jump.
when i hold either left+up or right+down, he cant jump.
for now ill leave this aside since i can jump then move diagnolly. any possible reason why this might happen?
how to controll the gravity?, cause i think when the character is jump, the jump is too long in the air, so it's like floating. would you help me
Hi, there are two ways you could do this.
First you could increase the gravity in the physics settings. Editor -> Project Settings -> Physics
Alternatively, you could add a gravity multiplier in the script. So where we apply the gravity would look something like this
ySpeed += Physics.gravity.y * gravityMultiplier * Time.deltaTime;
Then you could set the gravityMultiplier to 1.5 for example to increase the gravity applied.
Hope that helps 😊
@@KetraGames OOOOhhhhh i see... thanks for your explanation it helped me a lot
@@KetraGames While your suggestion is good, why not just do something like
(start of script)
public float gravity = ;
(gravity logic)
ySpeed += gravity * Time.deltaTime;
Is there a reason to use Unity's prebuilt gravity? Maybe NPCs are using rigidbodies, so it's easier to adjust their gravity later on without having to then go back to adjust the player's multiplier.
Am I just pointing out useless solutions, or is there a reason to do it your way that I'm missing?
@@washurpaws Hi, either way would work, but using the Unity gravity value is a useful global setting that can be used so that all objects in the game are using the same value for gravity. Having a multiplier then allows different objects to fall faster or slower than this value as desired
thank you :D
👍😊
my character still jumps continuously if i press the space bar. The isGrounded doesnt seem to be working. Am i right in thinking isGrounded isnt set as private bool
does this jump code work with rigidbody character controllers?
for some reason the ySpeed value does not stop decreasing and my character doesnt touch the ground to trigger the isGrounded bool
nvm i found the bug
@@alpha3836 whats the soulution
a good tutorial video, but I'm still tormented by the question of how to make a character fall faster than he gains height
I think Iheartgamedev has a video about recreating the Mario jump with animation curves I think.
THANKS A LOT!
ty
👍😊
Is this tutorials works with a PS5 controller? I’m a beginner and thanks.
Hi, yes this should work with any controller.
2:23 what if I don't have a light bulb? please help me thanks
Hi, the lightbulb helps you refactor code quickly but if you don't have it you can type the changes manually and get the same result. Hope that helps 😊
Can you tell, how to use jump with character contorll if button is UI based? not keyboard based?
Hi, what you could do is replace the key check with a check on a boolean field. So instead of
if (Input.GetButtonDown("Jump"))
{...}
you could do
if (jumpButtonPressed)
{
...
jumpButtonPressed = false;
}
You would then need to wire up the button click event to a method that sets this field to true.
We're planning to do some tutorials on mobile controls in the future but hope this helps in the meantime.
My hero!
😂😊
How about touch screen input, like going ball game, can u do a tutotrial about the mecanism used(going ball),thx
Thanks for the suggestion. We'll definitely be covering mobile input in future videos
@@KetraGames i hope u will make it as soon as possible, thx for ur great content.
do these tutorials still translate if use a rigid body for my player?
Hi, they won't exactly translate but there will be lessons you can learn and apply when using a rigidbody
Will you do a tutorial to prevent air movements while jumping ?
Thanks for the suggestion. We'll add it to the list of future videos 😊
Good to know 🙂
For some reason it only jumps when I move
That's a lovely accent you have there, New Jersey?
Thanks! I'm in the UK 😊
If I want to add force to the Y axis of an object ignoring the environment Y axis , Because the object mute flip and I don't want to push it it from the back. what should I write?
Hi, sorry I don't fully understand the question. If you are adding force to a Rigidbody and you don't want it to flip then you can lock the rotation on any axis. Hope that helps
My character is shaking uncontrollably when i click play, can someone help?
Hey, I've been wanting to create an auto-jump mechanic like the one from Ocarina of time, I've watched tons of movement/ jump tutorials, searched on forums and haven't found anything close to it, could you make a tutorial on this? I'm a newbie and your videos have been really helpful, thanks.
Hi, that sounds like an interesting challenge. We'll add it to the list of future videos.
I think the way that you would go about this would be to cast a Ray down toward the ground just ahead of your character. If you detect that there is no longer any ground ahead of the character, then trigger the jump.
How do I specify which layer is the ground layer? At this point my character jumps on everything and the .isGrounded return true eachtime.
Hi, you could use the OnControllerColliderHit method to get more detail on what the character has collided with. Then you could check if it's in the ground layer to enable the jump.
docs.unity3d.com/ScriptReference/ControllerColliderHit.html
Character can only jump when moving else jump is not working at all. By increasing ySpeed it's working.
Why does the character shift a little when the program starts? I noticed that the little red alien goes from 0 for Y to -0.0199 and my own test with a cube goes from 0 to 0.0800. Is there a way for it not to do that?
Hi, you could try repositioning the CharacterController slightly so that it starts off on the ground
for some reason my character just falls through the floor. can anyone help me with this problem?
Hi, have you got a collider component on the floor?
Can you move in mid air when you jump
Hi. Yes, you can move in the air 😊
Upon finishing code at 3:00 I can no longer move my character at all, much less jump
Sorry to hear you're having issues. Have you tried copying the code from here to see if that helps - dotnetfiddle.net/0GDAm3
Please also tell how can we add jump with UI button as the game can be for mobile.
Hi, what you could do is replace the key check with a check on a boolean field. So instead of
if (Input.GetButtonDown("Jump"))
{...}
you could do
if (jumpButtonPressed)
{
...
jumpButtonPressed = false;
}
You would then need to wire up the button click event to a method that sets this field to true.
We're planning to do some tutorials on mobile controls in the future but hope this helps in the meantime.
for some reason when i jump the player gets stuck in the air for a second then goes back down. It only happens when the player isnt moving its good when im moving
Hi, sometimes the jump can feel a bit floaty using the default gravity value. Try replacing Physics.gravity with a higher value and see if that helps
thanks
👍😊
Hello please help me.. i followed every step and i am getting issue that my player is getting back to ground very slower like its get back on ground in slow motion how can i fix this please help ...
Hi, it sounds like the gravitational acceleration isn't working properly. Check the line where you add the gravity and check you have it like this
ySpeed += Physics.gravity.y * Time.deltaTime;
You can also find the complete script at dotnetfiddle.net/0GDAm3. Hope that helps
@@KetraGames thank you so much ❤️
Nice trick setting step offset to 0
Thanks 👍
how do we edit the script to add a double jump?
I'm not the original creator of the video, but how I would do it is maybe have a second variable for "has the player doublejumped"? If the player presses the jump button and is grounded, it does the ground logic, but if they are not grounded, Unity will see if the doublejump boolean is true or false. If it allows doublejumping, it does the jump logic again, and marks the doublejump as true. When you're grounded, the doublejump allowed flag is set to true for the next time you need to jump.
my character movement is very laggy for some reason
Hi, not sure why that would be. Do you mean it doesn't respond to input quickly enough?
Wait it's OK the order of the script was wrong so sorry
it is probably good in a series but it is confusing for someone who is just tying to learn how to code a jump correctly.
I dunno why but my character just goes down even when there is a floor;
Hi, does your ground have a collider attached? If so, check that it isn't set as a Trigger.
3:13
sorry but not good for me code working but ingering in my movement
You ia single?
bad tutorial dont expect me to ruin my previously made movement physics just to suit yours
Sorry you didn't find this tutorial helpful. There are always multiple ways to solve a problem in software development so you can take concepts covered in the video and adapt them however you like.
Ahahah that's so rude and you clearly don't know programming and are just looking to copy tutorials
💀💀💀