sometimes when i jump it doesnt work properly, i need to click multiple times for it to work, im following the brakeys 1st person player movement tutorial
help please.
my code: ```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
#region Var
//Movement Var
public CharacterController CONTROLLER;
public float playerSPEED = 25f;
//Gravity Var
public float GRAVITY = -9.81f;
Vector3 velocity;
//GroundCheck Var
public Transform groundCHECK;
public float groundDISTANCE;
public LayerMask groundMASK;
bool isGrounded = false;
//Jump Var
public float jumpHIGHT = 3F;
#endregion
// Update is called once per frame
void Update()
{
//Input
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
//IsGrounded Code
isGrounded = Physics.CheckSphere(groundCHECK.position, groundDISTANCE, groundMASK);
velocity.y += GRAVITY * Time.deltaTime;
if(isGrounded) {
velocity.y = 0;
}
//Calcutating Direction To Move
Vector3 move = transform.right * x + transform.forward * z;
//Moving
CONTROLLER.Move(move * playerSPEED * Time.deltaTime);
//Jump
if (Input.GetButtonDown("Jump"))
{
velocity.y = Mathf.Sqrt(jumpHIGHT * -2 * GRAVITY);
}
//Gravity
CONTROLLER.Move(velocity * Time.deltaTime);
}
}```