# Character wont jump

**URL:** https://discussions.unity.com/t/character-wont-jump/811801
**Category:** Scripting
**Tags:** Scripting
**Created:** [October 7, 2020, 8:41pm UTC](https://discussions.unity.com/t/character-wont-jump/811801 "2020-10-07T20:41:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Zaye](https://avatars.discourse-cdn.com/v4/letter/z/9de053/32.png) [@Zaye](https://discussions.unity.com/u/Zaye)
#### Post date: [October 7, 2020, 8:41pm UTC](https://discussions.unity.com/t/character-wont-jump/811801/1 "2020-10-07T20:41:01Z")

</div>

Following this guide one youtube

> **[FIRST PERSON MOVEMENT in Unity - FPS Controller](https://www.youtube.com/watch?v=_QajrabyTJc%7Cstart=364)**
>
> Let's see how to get an FPS Character Controller up and running in no time!REGISTER with APPTUTTI: https://www.apptutti.com/partners/registration.php?utm\_sou...

(starts at 21:50)  
followed it exactly, or at least I think, but my character wont jump. I can walk around, turn, and have gravity but no jumping

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playermovementscript : MonoBehaviour
{
    public CharacterController controller;

    public float speed = 12f;
    public float gravity = -9.81f;
    public float jumpHeight = 3f;

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;

    Vector3 velocity;
    bool isGrounded;

    // Update is called once per frame
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if(isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        if(Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }

        velocity.y += gravity + Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}

```

---

<div class="post-metadata">

### Author: ![StarManta](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/starmanta/32/280327_2.png) [@StarManta](https://discussions.unity.com/u/StarManta)
#### Post date: [October 7, 2020, 8:54pm UTC](https://discussions.unity.com/t/character-wont-jump/811801/2 "2020-10-07T20:54:04Z")

</div>

Make isGrounded public and watch its value in the inspector. Is “isGrounded” ever set to true? If not, you may not have set up your layers or masks correctly.

---

<div class="post-metadata">

### Author: ![Zaye](https://avatars.discourse-cdn.com/v4/letter/z/9de053/32.png) [@Zaye](https://discussions.unity.com/u/Zaye)
#### Post date: [October 7, 2020, 9:00pm UTC](https://discussions.unity.com/t/character-wont-jump/811801/3 "2020-10-07T21:00:07Z")

</div>

> [@StarManta](#):
>
> Make isGrounded public and watch its value in the inspector. Is “isGrounded” ever set to true? If not, you may not have set up your layers or masks correctly.

I apologize, I just started learning this stuff. what do you mean make isGrounded public?

---

<div class="post-metadata">

### Author: ![StarManta](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/starmanta/32/280327_2.png) [@StarManta](https://discussions.unity.com/u/StarManta)
#### Post date: [October 7, 2020, 9:18pm UTC](https://discussions.unity.com/t/character-wont-jump/811801/4 "2020-10-07T21:18:05Z")

</div>

Put the word “public” in front of line 19, just like the fields above it like groundMask. If you look at that in the Inspector, you will now see a checkbox; that checkbox will be checked if the boolean is “true” and unchecked if it’s “false”.

---

<div class="post-metadata">

### Author: ![Kurt-Dekker](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/kurt-dekker/32/101578_2.png) [@Kurt-Dekker](https://discussions.unity.com/u/Kurt-Dekker)
#### Post date: [October 7, 2020, 9:18pm UTC](https://discussions.unity.com/t/character-wont-jump/811801/5 "2020-10-07T21:18:28Z")

</div>

Interestingly, it appears recent versions of Unity no longer work with this approach, calling .Move() twice.

I did an investigation about it and reported my findings here:

> [@How to correctly setup 3d Character Movement in Unity?](https://discussions.unity.com/t/811250):
>
> Hey there, so I’m a fairly new user on Unity and just started to test out the engine and C#. I have a question regarding Character Movement in Unity. I’ve used this specific code found from the Documentation: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Example : MonoBehaviour { private CharacterController controller; private Vector3 playerVelocity; private bool groundedPlayer; private float playerSpeed = 2.0f; private float jump…

In that post I also fixed the default Unity movement script example from the CharacterController script reference page. It appears the script above is somewhat derivative of that original broken script, at least inasmuch as it calls .Move() twice.
