Inconsistent Jump Heights
https://www.youtube.com/watch?v=mZvxnvrlYI8 I am using a raycast to check for Ground and it made my jumps all inconsistent, how can I fix this? here is my code https://pastebin.com/FBwfh92b
Answer by hemiechinuss · Feb 20 at 12:03 AM
It looks like the force applied to the rigidbody is dependent on how long the object believes it's colliding with the ground. So if the object quickly realises that it is no longer touching the ground then the resultant force is less than if it takes some time to realise that it is no longer grounded. Some things that might affect this is the use of the Update method rather than FixedUpdate, the use of Input.GetKey() rather than Input.GetKeyUp(), and also that due to the raycast length restriction it might not be colliding properly. Better I think to have an infinite length to the raycast then check the distance with Vector2.Distance() inputting only the y axis of each object to ensure the distance only takes into account the y axis and not the x.
A way to test this is to use Debug.Log("") to check if and for how long the raycast is colliding with the ground, and what force is being applied to the player with rb.velocity.
Your answer
Follow this Question
Related Questions
2d project a shadow below the player 0 Answers
One 2D Raycast Not Stopping Even Though Others Do? 0 Answers
Need help making a ledge climber. The problem, transform.position always returns to vector( 0, 0) 0 Answers
Help with using 3D code for a 2D game.(It's probably an easy fix) 1 Answer
How can make it so only 1 object of type “Ability” can be selected at once? 0 Answers