Gravity and characterController?

using UnityEngine;

public class Moving : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    [SerializeField] CharacterController character;
    [SerializeField] GameObject Nok;
    [SerializeField] GameObject Ball;
    [SerializeField] MYJS  myjs;
    float speed;
    Vector3 Direction;
    [SerializeField] Rigidbody BallRb;
    public bool Catch;
    public float Distance;
    public bool Onfloor;
    void Start()
    {
        
    }
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        
    }


    // Update is called once per frame
    void Update()
    {
        Direction = (Nok.transform.position - transform.position).normalized;
        Distance = Vector3.Distance(BallRb.position, transform.position);

        if (character.isGrounded == false)
        {
            Direction.y = Physics.gravity.y ;
            
            
            
        }
        if (character.isGrounded == true)
        {
            Direction.y = 0;
            

        }
        
      
        

       
            
            character.Move(Direction * speed * Time.deltaTime);
        }
    }
    


Why doesnt gravity apply to the character controller this code?

CharacterController does not handle gravity. See the docs:

Description

A CharacterController allows you to easily do movement constrained by collisions without having to deal with a rigidbody.

A CharacterController is not affected by forces and will only move when you call the Move function. It will then carry out the movement but be constrained by collisions.

If you just need a CC script, here’s two possibilities:

Here is a super-basic starter prototype FPS based on Character Controller (BasicFPCC):

And here is a free Kinematic Character Controller that also comes with a huge playground:

Thanks:)))))))))