- Home /
Much higher jump height when next to a wall
Hi,
So I'm trying to make a relatively simple script which allows the player to move left and right and jump/walljump. The only problem is, whenever the character is even near a wall, moving or not, jumping launches them much higher than it should into the air (~100 wu).
I've added kinematic rigidbodies to the walls & used custom gravity as suggested in another thread but the problem persists.
The player controller script is here
Jumpheight and speed are both 7.5, distance from wall is 0.2 and the walljump modifier is 1.
Thanks
Have you set custom physics materials to your objects? Have you tried modifying angular drag and bouncyness?
Answer by Roiw · Nov 18, 2017 at 12:47 AM
Hey Oscar,
On the same like you check if the player presses "arrow up" to jump, you also call the canJump() to verify if the player can jump. Afterwards you add force (to move the player) and then you set jumpingXMod to zero. I believe you set jumpingXMod to avoid adding too much force to the player.
However every time you do the canJump() verification you modify the jumpingXMod value.
That means the line where you zero jumpingXMod, never actually get to modify the value for the next Update interaction. Getting your player to fly higher than it should.
Hope it helps.
Have a great day :)
Answer by mafima · Nov 17, 2017 at 05:50 PM
for that cases a groundcheck can help. this helper can prevent multiple jumps while near to a wall. check the standard asset characters.
Your currently using raycast, which is better than oncollision, but not the best. unity provides you already with a much better groundcheck than I chould provide, so just be inspired by these scripts asset store -> standard assets.
Your answer
![](https://koobas.hobune.stream/wayback/20220612142948im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I make an object stop all momentum and hold it's position in air? 1 Answer
2D Mouse Aiming on Unity 4.3 1 Answer
2d enemy ai 0 Answers
2D Wall Jump Problem 0 Answers