Hello,
I have a small script that checks a variable, and if that variable is true, it will enable Rigidbody on the same GameObject and if it’s false, it will disable it. I am remotely modifying the variable with another script but that’s not the matter.
My problem is that .enabled is not recognized by Unity, and I get this error:
Type UnityEngine.Rigidbody' does not contain a definition for
enabled’ and no extension method enabled' of type
UnityEngine.Rigidbody’ could be found (are you missing a using directive or an assembly reference?)
Here is the script:
public class ObjectSettings : MonoBehaviour {
public bool hasGravity;
public Rigidbody rig;
void Start () {
rig = GetComponent<Rigidbody>();
}
void Update () {
if (hasGravity) {
rig.enabled = true;
}else {
rig.enabled = false;
}
}
}
Thanks!