Hello, here’s my script that is attached to every wheel:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class check_ifgrounded : MonoBehaviour
{
void OnCollisionEnter(Collision collision)
{
GameObject.Find("CAR").GetComponent<Driving>().wheels_grounded = GameObject.Find("CAR").GetComponent<Driving>().wheels_grounded + 1;
}
void OnCollisionExit(Collision collision)
{
GameObject.Find("CAR").GetComponent<Driving>().wheels_grounded = GameObject.Find("CAR").GetComponent<Driving>().wheels_grounded - 1;
}
}
and that’s a problem: “wheels_grounded” value is always showing “0”, what I’m doing wrong?