failing to access height of a capsuller collider

im trying to access height of a capsuler collider so that i can use it with in a function but i keep getting this error
Custom_scripts/CH_Controller.js(20,70): BCE0019: ‘height’ is not a member of ‘UnityEngine.Collider’.
below is an extract of my code

if(Physics.Raycast(transform.position,-transform.up,collider.height/2 + 0.2))
		{
		isGrounded=true;
		Jumping= false;
		inAir=false;
		
		}

i later tried defining height as below but it also didnt work

function Start () {
var robotCollider = gameObject.GetComponent(CapsuleCollider);

}

function FixedUpdate () {
if(!isGrounded){
if(Physics.Raycast(transform.position,-transform.up,robotCollider.height/2 + 0.2))
{
isGrounded=true;
Jumping= false;
inAir=false;

	}

``}

Ah you are skirting around the answer :slight_smile:

So you correctly guessed that collider isn’t going to be a capsule collider (and therefore doesn’t have the height variable) - actually it is a capsule collider but the way you are accessing it the compiler doesn’t know that.

    (collider As CapsuleCollider).height

Will give you the height (presuming collider is a CapsuleCollider, otherwise it’s a null reference)

Your GetComponent was a good idea - but you defined it as a local variable - so that approach you should have made it a private class variable. Basically FixedUpdate doesn’t have a robotCollider in it!

    var robotCollider : CapsuleCollider;

    function Start() 
    {
          robotCollider = GetComponent(CapsuleCollider);
    }