I’m not trying to convert an int to a bool. I am scripting in c sharp and when I come to this line it throws out this error!
r.drag = body.grounded ? 1 : 0.1f;
Why does this error pop up? r is the name that I gave to the rigidbody of body, grounded is a bool that shoes whether or not the player is touching the ground. Thanks for any help!
Since your “grounded” variable is an int you have to convert it to a boolean state “is grounded”. From your code it seems that you’re grounded when the “grounded” integer is greater than 0, so just use the greater-than operator like this:
r.drag = (body.grounded > 0) ? 1f : 0.1f;
Alternatively you could also add this property to your PlanetaryGravity class:
public bool IsGrounded
{
get {return grounded > 0;}
}