- Home /
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?
Edit:
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.
Your source code might help, but I'd guess that holding down the 'W' adds more force causing the character to jump faster. Is your character driven by a Character Controller or a Rigidbody?
Answer by robhuhn · Aug 26, 2013 at 06:51 AM
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.
Okay, the force is being applied in the update function, and that is definitely the problem. Seems simple now that I think about it. I'll work on fixing it, thanks for the help.
Your answer
Follow this Question
Related Questions
Raycast for 2d with touch. 0 Answers
Help for raycasting 2d with multiple layers 1 Answer
My Raycasts seem to sometimes miss 0 Answers
Test line renderer collision? 1 Answer
Add collision to raycasted object? 2 Answers