Player doesn't jump

Hey there!
I wrote the same code as Rick in the video and also checked it in the * This Lecture’s Github Commit
Everything is the same. But when I press play, my character doesnt jump. Has anyone an idea why?
This is the code I wrote, just in case I did a silly mistake (I use the 2019.04 version of Unity).
private void Jump()

{
    if (!myCollider2D.IsTouchingLayers(LayerMask.GetMask("Ground"))) { return; }

    if (CrossPlatformInputManager.GetButtonDown("Jump"))

    {
        Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
        myRigidBody.velocity += jumpVelocityToAdd;
    }
}
1 Like

Put a print statement in the function and make sure it’s actually getting called. Also I would make sure your ground has the correct layer assigned to it.

Hey Riley!
Thanks for your reply. In the end I don’t know what the problem was. I first looked and searched online for a solution, but nothing worked. Today I gave up and thought, why not type it again, maybe for once that will work, and voila, it did! :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms