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

I’m desperately fighting for some answers here.

ignoring the stuff thats been disabled, what am I doing wrong here? And why doesn’t unity recognise height? Information taken from this tutorial: Search | Packt Subscription

the “height” problem is found under “fixed update”. Please hlep, thanks. I have no idea what’s happening.

#pragma strict

var health : int = 100;
//var speed : int = 5;
//var jumpSpeed: float = 8;
//var isgrounded : boolean = true;

public var jumpSpeed : float = 500.0;
public var jumpDirection : Vector3 = Vector3.zero;
public var isGrounded : boolean = false;
public var Jumping : boolean = false;
public var inAir : boolean = false;
public var airControl : float = 0.5;
public var MoveDirection : Vector3 = Vector3.zero;
public var Speed : float = 5.0;

function Start () {

}


function Update () {


//	if(isgrounded == true){
//		if (Input.GetKeyDown (KeyCode.Space)){
//		rigidbody.velocity += Vector3.up * jumpSpeed;
//		Physics.gravity = Vector3(0,-50,0);
//		}
//}




//	if(Input.GetAxis("Horizontal")){
//		transform.Translate(Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0, 0));
//	}
    
	var AT = gameObject.GetComponent(AnimateTexture); //Store AnimateTexture Script
	if(Input.GetKey("a")){ //Player moves left
		AT.rowNumber = 1; //Change to running animation
	} else if(Input.GetKey("d")){ //Player moves right
		AT.rowNumber = 1; //Change to running animation
	} else { //Player is not moving
		AT.rowNumber = 0; //Change to idle animation!
	}
	if(Input.GetKey("space")){
		AT.rowNumber = 3; //Player jumping animation
	}
	if(Input.GetKey("up")){
		AT.rowNumber = 3; //Player jumping animation
	}
	if(Input.GetKey("s")){
		AT.rowNumber = 4; //Player squats down
	}
	if(Input.GetKey("left")){
		AT.rowNumber = 1;
	}
	if(Input.GetKey("right")){
		AT.rowNumber = 1;
	}
	if(Input.GetKey("down")){
		AT.rowNumber = 4;
	}   
}

//	function OnCollisionEnter(theCollision : Collision){
//if(theCollision.gameObject.name == "floor"){
//		isgrounded = true;
//	}
//}

//	function OnCollisionExit(theCollision : Collision){
//	if(theCollision.gameObject.name == "floor"){
//		isgrounded = false;
//	}
//}




function FixedUpdate (){
    if (!isGrounded){
        if (Physics.Raycast(transform.position, -transform.up, collider.height/2 + 0.2)){
            isGrounded = true;
            Jumping = false;
            inAir = false;
         }
        else if (!inAir){
            inAir = true;
            jumpDirection = MoveDirection;
         } 
     }  
Movement();
}
function OnCollisionExit(collisionInfo : Collision){
    isGrounded = false;
}




function Movement(){
	if (Input.GetAxis("Horizontal") || Input.GetAxis("Vertical")) {
	MoveDirection = Vector3(Input.GetAxisRaw("Horizontal"),
	MoveDirection.y,Input.GetAxisRaw("Vertical"));
	}
	if (Input.GetKeyDown("space") && isGrounded){
	
		if (Input.GetButtonDown("Jump") &&isGrounded){
			Jumping = true;    
			jumpDirection = MoveDirection;
			rigidbody.AddForce((transform.up) * jumpSpeed);
	
		}
	if (isGrounded)
		this.transform.Translate((MoveDirection.normalized * Speed) * 
		Time.deltaTime);
		else if (Jumping || inAir)
		this.transform.Translate((jumpDirection * Speed * airControl) * 
		Time.deltaTime);


	}
}

The tutorial was probably relying on dynamic typing. It’s a powerful language feature, but it’s not supported on mobile and is disabled when you’re using #pragma strict.

(Side note: I’m of the opinion that you should always use strict. You can code faster without it, sometimes, but it’s really easy to miss problems like this one.)

Some colliders, such as CapsuleCollider, do have a height attribute. The reference returned by collider doesn’t know which type of collider is attached, though, so it returns the most general type it can: Collider.

If you know for sure that it’s a capsule collider, you could cast the reference:

((CapsuleCollider)collider).height

As an alternative, every collider also has a bounds attribute you could use:

collider.bounds.size.y