- Home /
Question by
bhambhu · Nov 11, 2013 at 11:03 AM ·
collisioncharactercontrollerlogic
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 . :)
Comment
I dont see where your character actually dies in your code. What is called for your character death?
Answer by static_cast · Nov 11, 2013 at 04:18 PM
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.
Your answer
Follow this Question
Related Questions
CharacterController & Particles 1 Answer
Character Controller vs. Kinematic Rigidbody 1 Answer