Object jumps through roof when holding "Up" button?

In my 2d game, I have a simple cube for testing. I am using raycast for collision detection. I have loosely been following a tutorial. I originally was using the space as my jump key but recently changed it to use the vertical axis, and now when I hold down the “W” key my character will jump through a platform above it. Although when I quickly press “W” it will collide with the platform above it. Any idea what is causing this and how I can fix it?


The source code is really 2 really long scripts that interact with each other, I wouldn’t want anybody putting that much effort into it. I was just hoping there it would be a simple solution to a simple problem. And it is driven by a rigidbody.

Either the force to jump is applied multiple times e.g. within an Update/FixedUpdate or the value of force is much too high or gravity in the editor has a low value (Edit->Project Settings->Physics) or useGravity on rigidbody is not checked or another reason.