[2D] Trying to make my character jump using addForce, but it's not working.,Rigidbody2d.AddForce isn't working.
Trying to make my character jump, but no matter what I do it's not working, it just doesn't move the character at all. Any help is appreciated.
void Jump()
{
if (Input.GetButtonDown("Jump") && isGrounded == true)
{
Vector2 jumpForce = new Vector2(0f, 2f);
rb2D.AddForce(jumpForce, ForceMode2D.Impulse);
}
}
Hi. Firstly, add a Debug.Log statement under the AddForce line just to see if that part of the code is executing. Secondly, the force you add might be too small to see any difference. Create the jumpForce Vector2 at the top of the class and make it public so you can change it from the inspector at runtime. Then, at runtime try changing its value to see if the character jumps. Don't hesitate to ask further questions.
Your answer
Follow this Question
Related Questions
Walking around 2D planets? 1 Answer
Player controlled platforms 0 Answers
[2D] Rigid body snaps through floor and back 1 Answer
Problem with my dash ability, 1 Answer
Unity Sprite renderer bug?? 0 Answers