isGrounded script not working

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

    public CharacterController canDubJump;
    private float dubjump = 0;
    private float JumpSpeed = 200.0f;
    private Rigidbody rb;
    public float Multiplier;
    void Start () {
        rb = GetComponent<Rigidbody>();
        canDubJump = GetComponent<CharacterController>();
    }
   
    void Update () {
       
        float movehorizontal = Input.GetAxis("Horizontal");
        float movevertical = Input.GetAxis("Vertical");
        Vector3 movement = new Vector3(movehorizontal, 0.0f, movevertical);

        rb.AddForce(movement * Multiplier);

        if (canDubJump.isGrounded)
        {
            print("We are Grounded");
        }
        if (canDubJump.isGrounded && Input.GetKeyDown(KeyCode.Space))
        {
            rb.AddForce(Vector3.up * JumpSpeed);
        }

    }
}

For a platformer game I’m creating, I am trying to implement a jump mechanism that doesn’t allow infinite jumping, but the code posted above doesn’t work, and the ball doesn’t jump. Do I have to add a component to the object which is my ground?

Check the first line in the CharacterController documentation: the CharacterController is NOT meant for use with Rigidbodies.

Quote: The Character Controller is mainly used for third-person or first-person player control that does not make use of Rigidbody physics.

Google around and you can find Rigidbody-based controllers too, but the basic Unity Character Controller is not intended to be used that way:

either check the ‘is kinematic’ checkbox or use any one of the Controller(Character Controller or rigidbody):wink: