Error: Cannot convert method group 'x' to non-delegate type 'bool'.

Cannot convert method group ‘IsGrounded’ to non-delegate type ‘bool’. Did you intend to invoke the method?

Please help me, how do I fix this?

using System.Collections;
using UnityEngine;

public class WallRun : MonoBehaviour {

    public bool isWallR = false;
    public bool isWallL = false;
    private RaycastHit hitR;
    private RaycastHit hitL;
    private int jumpCount = 0;
    public PlayerMovementController cc;
    public Rigidbody rb;
    public Transform cameraEffect;
    public Animator anim;
    public bool canJump;


void Start () {
     
}
  
    void Update()
    {
        if (cc.IsGrounded())
        {
            jumpCount = 0;
            isWallL = false;
            isWallR = false;
        }
        if (isWallR == true && isWallL == false)
        {
           
            anim.SetBool("Left", true);
        }
        if (isWallR == false)
        {
           
            anim.SetBool("Left", false);
        }
        if (isWallL == false)
        {
           
            anim.SetBool("Right", false);
        }
        if (isWallR == false && isWallL == true)
        {
          
            anim.SetBool("Right", true);
        }

        if (canJump == true && Input.GetKeyDown(KeyCode.Space))
        {
            rb.AddForce(Vector3.up * 100, ForceMode.Impulse);
            if (isWallL == true)
            {
                Vector3 force = this.transform.right * 200;
                rb.AddForceAtPosition(force, this.transform.position, ForceMode.Impulse);
            }
            if (isWallR == true)
            {
                Vector3 force = -this.transform.right * 200;
                rb.AddForceAtPosition(force, this.transform.position, ForceMode.Impulse);
            }
        }
       
        if (cc.IsGrounded)
        {
            if (Physics.Raycast(transform.position, transform.right, out hitR, 1))
            {
                if (hitR.transform.tag == "Wall")
                {
                    canJump = true;
                    isWallR = true;
                    isWallL = false;
                    jumpCount += 1;

                    rb.useGravity = false;
                }
            }
            if (!Physics.Raycast(transform.position, transform.right, out hitR, 1))
            {
                   
                    isWallR = false;
                    jumpCount += 1;
                if (isWallL == false)
                {
                    canJump = false;
                    rb.useGravity = true;
                }
            }
            if (Physics.Raycast(transform.position, -transform.right, out hitL, 1))
            {
                if (hitL.transform.tag == "Wall")
                {
                    canJump = true;
                    isWallL = true;
                    jumpCount += 1;
                    rb.useGravity = false;
                }
            }
            if (!Physics.Raycast(transform.position, -transform.right, out hitL, 1))
            {
               
                isWallL = false;
                jumpCount += 1;
                if (isWallR == false)
                {
                    canJump = false;
                    rb.useGravity = true;
                }
            }
        }
    }
}

I want to use a part of a script that I wrote and is in the project.
The error is at 66:16, please help and thank you!

It means that your code cc.IsGrounded doesn’t return a bool as you have it typed.

Is “IsGrounded” a method? Should it be cc.IsGrounded() ?

2 Likes

If IsGrounded is a method, you need the () after it, just like you have earlier in the script

Thank you so much, I didnt realize, thanks alot!

Thanks for the help! Im new to this and didnt realize.