Problem with my movement code

So I am developing an online multiplayer FPS game for my SDD major work, and I have run into a problem. Below is the movement code for my player. I am trying to implement strafing and bunnyhopping into my game, and so I setup a test environment within my project and I managed to get everything working. The only problem was that after I tried to put this back into my main project, it stopped working.

The main problem is that the jumping only works sometimes. The player only jumps a very small amount, and sometimes stay there, meaning that there is no friction as the player is stuck off the ground. He also seems to phase beneath the ground a tiny bit, but the collider on him shouldn’t let that happen. I have tried to remove the code that makes downward falls faster, but that only fixes it sometimes.

If this isn’t enough, I can try to explain it more, or even upload the files for you to have a look at. I have been trying to fix this for like 6 hours now and I have no idea anymore. Any help would be greatly appreciated

Code link: Movement Code - Pastebin.com

I had exactly the same problem when I switched to rigid body. It turns out that the problem was this:

if (Input.GetKey("space") && isGrounded())

What was happening in my case, was that the update function sometimes captured a single key press and sometimes captured it multiple times in a fraction of a second, depending on how long you kept the key down and the timing of the internal logic processes.

Try to use GetKeyDown instead. This will make sure the key event is registered only once, until it is released and pressed again. Notice that, you will probably need to tune the jumping force after this change.

I really hope this helps.