Death Condition ??

Hello Friends . I am using character controller for my character . now , i am confused about the death of my character when it collides with something . Currently i am using following code …

function OnControllerColliderHit(hit:ControllerColliderHit){
    var hitPoints:Vector3=transform.InverseTransformPoint(hit.point);
	var diff=hit.point-transform.position;
	if(diff.z>=.5){ // .5 is radius of Character Controller
	    Camera.main.GetComponent(mainController).isPlay=false;
	}
	

}

But , its not working properly . Please tell me where i am wrong and guide me in correct direction . :slight_smile:

function OnControllerColliderHit(hit : ControllerColliderHit)
{
var hitPoints:Vector3=transform.InverseTransformPoint(hit.point);
var diff=hit.point-transform.position;
if(diff.z >= 0.5) //.5 is radius of Character Controller
Camera.main.GetComponent(mainController).isPlay=false;
}
only reformatted code

I’m pretty sure that the character controller has it’s own collision functions, but I’m not sure where you’re going with your code.