Search Unity

Question Need help resolving this error

Discussion in '2D' started by MaxTheBetterGamer, Apr 5, 2021.

  1. MaxTheBetterGamer

    MaxTheBetterGamer

    Joined:
    Apr 4, 2021
    Posts:
    3
    (29,27): error CS1002: ; expected





    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class GroundCheck : MonoBehaviour {



    void Start()
    {

    }

    void Update()
    {

    }
    private int countColliders = 0;

    private void OnCollisionEnter(Collision collision) {
    countColliders++;
    }

    private void OnCollisionExit(Collision collision) {
    countColliders--;
    }

    private void IsGrounded() {
    return countColliders 0;
    }

    }


    I tried to fix it but if i try to it gives me more errors, no articles online have helped either
     
  2. jbnlwilliams1

    jbnlwilliams1

    Joined:
    May 21, 2019
    Posts:
    267
    Private void IsGrounded() , being a void function, should not return anything. Make that line

    countColliders = 0;
     
    MelvMay and BenniKo like this.
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Please note for the future that the 2D forums are not for fixing general scripting errors. If you have a script issue then please post in the scripting forum. Your post isn't even related to 2D TBH (it's 3D physics).

    Finally, note that you post the error and line number but you don't use code-tags so the line isn't obvious. In your case the error is obvious though and thankfully someone above helped you correctly. :)
     
    BenniKo likes this.