My player can't jump

You are here:--My player can't jump
My player can't jump 2018-03-20T06:29:53+00:00

Home Forums 2D Platformer My player can't jump

Tagged: , ,

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Knnth
    Keymaster
    Post count: 2

    I’v decided to create a post dedicated to jumping errors. If you read this post, and it didn’t fix your jumping problem, then please let me know so that I can update it.

    What is ground
    You need to set what is ground to be able to jump, if you forget to do this, then the character don’t know that it can jump on the specified ground. This is done on the Player(script) in the inspector.
    What is ground example

    Jump force
    Make sure you have set a jump force, if you forget to set a jump force, then you character won’t be able to jump. The jumpforce is set on the Player(script)’s inspector.
    Jump Force

    Groundpoints & Radius
    Remember to assign your groundpoints in the inspector. You also need to make sure that the ground points are close enough to the ground to be able to check if the player is on the ground. The ground radius also need to be set.
    groundPoints

    Animation behaviours(Part 14.1 and up)
    Make sure the animation behaviours are attached to the correct animations. JumpBehaviour needs to be attached to TakeOff, LandBehaviour needs to be attached to Landing.

    Executing the code.
    You need to make sure that you are executing the code. This has to be done in Update. If you forget to call the code in Update, then it will never be executed. Update could look something like this:

        void Update()
        {
            HandleInput();
        }

    The jump code
    You might have some errors in the IsGrounded code. Here is my code so that you can compare.

        private bool IsGrounded()
        {
            if (MyRigidbody.velocity.y <= 0)
            {
                foreach (Transform point in groundPoints)
                {
                    Collider2D[] colliders = Physics2D.OverlapCircleAll(point.position, groundRadius, whatIsGround);
    
                    for (int i = 0; i < colliders.Length; i++)
                    {
                        if (colliders[i].gameObject != gameObject)
                        {
                            return true;
                        }
                    }
    
                }
            }
            return false;
        }
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
    • This topic was modified 11 months ago by  Knnth.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.