Question:I am actually trying to make the player Sprint by pressing the LeftShift key and Crouch by pressing the LeftControl Key.
I attached the C# Code at the bottom. So here, the Shift key works, because I tested by using Debug.Log(“Sprint Triggered”) when the key is pressed, and the Crouch key works too in the same way.
But, when I press Shift, the speed of the player doesn’t change at all. And also, when I press crouch, the player just gives a really really quick jump up.
I have set all the variables correctly, I double checked them. But I don’t know why there is no change in the motion of the body.
Let me know if you need any more details
Answer:The body is changing, just that its only in the moment you press down the key and then it returns to its normal state. You can make a function that checks for holding/releasing certain keys and modifies a bool variable that your sprint/crouch function will read, like this:
If you have better answer, please add a comment about this, thank you!