problem with Charactercontroller go up and down

this is miìy script for character controller but
when hen he climbs a hill if he is more inclined than 10 ° he does not go forward, he gets stuck and falls under the ground, instead, when he has to go down the hill he does it in jerks how can I solve

thanks

using System.Collections;
using System.Collections.Generic;
using UnityEngine.Diagnostics;
using UnityEngine;
using UnityEngine.UIElements;

public class CharacterController : MonoBehaviour
{

    [System.Serializable]
    public class MoveSettings
    {

        public float rotateVel = 100;
        public float forwardVel = 12;
        public float jumpVel = 25;
        public float distToGrounded = 0.1f;
        public LayerMask ground;
      



    }
    [System.Serializable]
    public class PhysSettings
    {
        public float downAccel = -0.75f;
       


    }
    [System.Serializable]
    public class InputSettings
    {
        public float inputDelay = 0.1f;
        public int jumpDelay = 1000;
        public float tapSpeed = 0.5f;
        public float slopeAngle;
       
    }

    public MoveSettings moveSetting = new MoveSettings();
    public PhysSettings physSetting = new PhysSettings();
    public InputSettings inputSetting = new InputSettings();
  


    Vector3 velocity = Vector3.zero;
    Quaternion targetRotation;
    Rigidbody rBody;
    Animator anim;
  
   
    public float forwardInput, turnInput ,jumpInput, runInput;
    public Quaternion TargetRotation
    {
        get { return targetRotation; }
    }

   /*bool Grounded()
    {
        return Physics.Raycast(transform.position, Vector3.down, moveSetting.distToGrounded, moveSetting.ground);
    }*/
   
    void Start()
    {
       
        //moveSetting.DisstanceToTheGround = GetComponent<Collider>().bounds.extents.y;
        forwardInput = 0;
        turnInput = 0;
        jumpInput = 0;
        runInput = 0;
       
        targetRotation = transform.rotation;
        if (GetComponent<Rigidbody>())
            rBody = GetComponent<Rigidbody>();
        else
        { Debug.LogError("the character needs rigidbody"); }
        if(GetComponent<Animator>())
        {
            anim = GetComponent<Animator>();
        }
        else
        { Debug.LogError("the character needs animator"); }
       
    }

    void GetInput()
    {
        forwardInput = Input.GetAxis(/*inputSetting.FORWARD_AXIS*/"Vertical");
        turnInput = Input.GetAxis(/*inputSetting.TURN_AXIS*/ "Horizontal");
        jumpInput = Input.GetAxisRaw(/*inputSetting.JUMP_AXIS*/ "Jump");
        runInput = Input.GetAxis("shiftrun");
      
    }

    void Update()
    {
        GetInput();
        Turn();
    }

    void FixedUpdate()
    {
        Run();
        Jump();
        rBody.velocity = transform.TransformDirection(velocity);
        attack();
        Grounded();
    } 
       

   

    void Run()
    {
       

        if (Mathf.Abs(forwardInput) > inputSetting.inputDelay)
        {
            //move rBody.velocity = transform.forward * forwardInput * moveSetting.forwardVel;

        

            velocity.z = moveSetting.forwardVel * forwardInput;

            if (Mathf.Abs(runInput) > inputSetting.inputDelay)
            {
                moveSetting.forwardVel = 30;
                anim.SetFloat("velocity", 2f);
               
               

            }
            else
            {
                moveSetting.forwardVel = 12;
                anim.SetFloat("velocity", 0f);
                anim.SetInteger("condition", 1);
            }
            anim.SetInteger("condition", 1);
           
           
            //rBody.velocity = transform.forward * forwardInput * moveSetting.forwardVel;
        }
        else
        {
            //  rBody.velocity = Vector3.zero;
            velocity.z = 0;
            anim.SetInteger("condition", 0);
            //rBody.velocity = Vector3.zero;
        }
       

    }

    void Turn()
    {
        if (Mathf.Abs(turnInput) > inputSetting.inputDelay)
        {
            targetRotation *= Quaternion.AngleAxis(moveSetting.rotateVel * turnInput * Time.deltaTime, Vector3.up);
        }
        transform.rotation = targetRotation;
    }
   
    void Jump()
    {

        if (jumpInput>0 && isGrounded)
        {
            anim.SetBool("jumpon", true);
           
            velocity.y = moveSetting.jumpVel;
           

            //moveSetting.stopJump = true;
        }
        else if (jumpInput==0 && isGrounded)
        {
            velocity.y = 0;
            anim.SetBool("jumpon", false);
          
        }
        else
        {
          
            velocity.y -= physSetting.downAccel;
          
        }



    }
    void attack()
    {
        if (Input.GetKeyDown("f"))
            anim.SetBool("attackon", true);
        else
            anim.SetBool("attackon", false);
    }

    public bool isGrounded = false;

    public void Grounded()
    {
        RaycastHit hit;
        if (Physics.Raycast(transform.position, Vector3.down, out hit, moveSetting.distToGrounded, moveSetting.ground))
        {
            inputSetting.slopeAngle = (Vector3.Angle(hit.normal, transform.forward) - 90);
           isGrounded = true;
        }

        else
        {
            isGrounded = false;
        }
    }
 
   
}

Your thread title and class name are confusing. Unity’s built in CharacterController class is spelled exactly the same, and what people think you are talking about until they spend time looking through your script. Probably not a good idea, though not your specific problem here.

On going down hills you’re not applying any downward force if isGrounded is true. So I’d expect moving forward would not move down the slope but instead directly forward, until isGrounded resolves to false and then the character falls. I’m assuming you have gravity disabled on this object. Is there a reason why you don’t just enable gravity and let Unity handle the downward force automatically, and don’t override the Y velocity other than when starting a jump? The way you’re currently doing it will result in a staircase effect.

As far as moving forward when going up the hill, you are just applying more Z velocity, so any movement up the hill is just it sliding/friction against the terrain collider instead of you applying some Y velocity upward (on top of that, you’re actually forcing Y velocity to 0f on line 180, which will prevent the physics system from applying some Y velocity automatically, pushing it up the hill, as a result of collision with the sloped terrain collider). Depending on physics materials involved, at a certain angle it just won’t move up the slope doing it like this I’m sure. You keep just applying velocity pressing against the collider and then you’re popping through it, which is what you see when it falls. Maybe using one of the continuous detection modes on the rigidbody will help prevent that from occurring. You used to be able to effectively make your terrain collider “thicker” to help address falling through the terrain, but I believe that was removed in the 2018.3 terrain system redesign.

ok thanks but what can I do to solve those problems?