- Home /
function for colliding without using rigid body's?
function OnCollisionEnter (collision : Collision) {
if(CrateMission.CrateMission == true) {
if(collision.gameObject.tag == "Player" && !isHit) {
isHit = true;
animation.Play("crate");
PlayerStats.CRATES +=1 ;
Destroy(gameObject,KillTime);
}
} }
here is my script however i believe i have to add a rigid body to both of the objects i have a charter with a mesh collider convex and i want him to collide with the crate then the function happens what is the best function to use i dont want to attach a rigid body to my worm but don't mind if it is attached to the crate
please help thanx :)
Format your code by selecting it and hitting the code format button.
Answer by e-bonneville · Jul 29, 2010 at 11:46 AM
Add a collider to the box. It's not the same as the rigidbody, and will allow your character to collide with it, triggering the collision function and the rest of your code.
i have tried this and the box collider does not seem to work with the function
Is 'Crate$$anonymous$$ission.Crate$$anonymous$$ission' true? It won't work unless that variable is true.
Your answer
Follow this Question
Related Questions
OnCollisionEnter not getting calle! 1 Answer
How can i call the 'col' object from the Update function? 1 Answer
2 objects collide, need to destroy one 2 Answers
Keep doing something while colliding 1 Answer
Little problem with OnTriggerEnter 1 Answer