'center' is not a member of 'UnityEngine.Collider'.

‘center’ is not a member of ‘UnityEngine.Collider’.

I literally can’t find a fix for this. I is basically one line of code:

distGround = collider.bounds.extents.y - collider.center.y; 

What this does is get center from colldier but center…is not a member of Collider? Unity console spells collider as Collder (capital C) but they are completely different things!
I think this is a recent problem since I got this script from a year ago.
But anyway, do you know a fix, I tried BoxCollider.center but it didn’t work for center and bounds.
Thanks anyway!

center isn’t a member of collider… Unity - Scripting API: Collider

Did you mean collider.bounds.center ?

Well, you’ve mixed up things a bit :wink: First of all the type of the “.collider” property is Collider and a collider doesn’t have a center. Derived types like a BoxCollider / SphereCollider have a center property. Since the type of the collider property is Collider you would have to cast it into the concrete type.

However, in your case it would make more sense to use the center of the colliders bounds since you also use the extents of the bounds. So your line should look like:

distGround = collider.bounds.extents.y - collider.bounds.center.y; 

I’m not sure what you want to calculate here since this calculation seems a bit strange. If you want the worldspace y position of the bottom edge of the bounding box you should do:

distGround = collider.bounds.center.y - collider.bounds.extents.y; 

or simply use:

distGround = collider.bounds.min.y; 

which does this calculation already for you.