Problem with gravity and character controller

Hello, i’ve bumped into little problem.

 void Update(){
    if(!mvmControl.isGrounded)
    moveDirection.y-=5; //gravity
    if(mvmControl.isGrounded) {
    moveDirection = newVector3(0,0,Input.GetAxis("Vertical"));
    moveDirection = transform.TransformDirection(moveDirection);
    }
    mvmControl.Move(moveDirection*Time.deltaTime);
    }

My mvmControl.isGrounded condition is always flickering true/false and i can’t ground my character :frowning:
With .SimpleMove everything is ok, but i want to use .Move for more control

Try this:


private float y;
private float z;
private Vector3 moveDirection;

 void Update()
{
    if(!mvmControl.isGrounded)
    {
       y -= 5f; //gravity
    }
    if(mvmControl.isGrounded)
    {
       if(y < -0.1f)
       {
          y = -0.1f;
       }

       z = Input.GetAxis("Vertical");
    }

    moveDirection = new Vector3(0, y, z);
    moveDirection = transform.TransformDirection(moveDirection);
    mvmControl.Move(moveDirection * Time.deltaTime);
}

That way, even if the character controller is grounded you will be applying a small downwards movement, forcing it to stay grounded.