title: Trouble with a Unity 3D movement script
body: <p><a href="https://i.stack.imgur.com/26fvo.png" rel="nofollow noreferrer">image of the scene. </a>I was using a tutorial online, then ran into issues when the code didn't work properly.</p>
  <p>My main issue is with the isGrounded variable. When used, it doesnt allow my sprite to jump, when its job is to prevent doube-jumps by only allowing you to jump when touching the ground, everything is linked up to the in-engine components, and i think the main issue is with the line:</p>
  <p><code>isGrounded=Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);</code></p>
  <p>the rest of the code is below. thanks for reading.</p>
  <pre><code>public class PlayerMovement : MonoBehaviour
  {
      public CharacterController controller;
      public float speed = 10f;
      Vector3 velocity;
      public float gravity = -20f;
      public Transform groundCheck;
      public float groundDistance = 0.4f;
      public LayerMask groundMask;
      public float jumpHeight = 3f;
      public float speedManager = 1.5f;
      bool isGrounded;
  
      // Start is called before the first frame update
      void Start()
      {
     
      }
  
      // Update is called once per frame
      void Update()
      {
  
  
          isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
  
          if( isGrounded &amp;&amp; velocity.y &lt; 0)
          {
              velocity.y = -10f;
          }
  
          float x = Input.GetAxis(&quot;Horizontal&quot;);
          float z = Input.GetAxis(&quot;Vertical&quot;);
  
  
  
          Vector3 move = transform.right * (x / speedManager) + transform.forward * z;
  
          controller.Move(move * speed * Time.deltaTime);
  
     
  
  
          velocity.y += gravity * Time.deltaTime;
  
          if (Input.GetButtonDown(&quot;Jump&quot;) &amp;&amp; isGrounded)
          {
              velocity.y = Mathf.Sqrt(jumpHeight * -10f * gravity);
          }
  
              controller.Move(velocity * Time.deltaTime);
  
  
  
      }
  
  }
  </code></pre>