- Home /
The question is answered, right answer was accepted
Mesh Collider & Rigid Body fail to detect trigger
I have a pocketknife inside my project which I imported through a .blend (Blender) file.
I want to have it as a collectable item by the user and thus, I want it to rotate and disappear once the MainChar has collided with it. So, I've added to the pocketknife a rigidbody (without the use of gravity because I want it to be on the air). Then, I've added to it a Mesh Collider whith 'Is Trigger' checked. Then I've attached this script to the pocketknife:
function OnTriggerEnter(hit:Collider){
Debug.Log("Something hit me!");
if(hit.gameObject.name=="MainChar"){
Destroy(gameObject);
hasKnife=true;
}
}
I don't even get the Something hit me!
message...
Answer by hakermania · Mar 11, 2013 at 02:23 PM
Altering the collider's size fixed the problem.
Answer by jonnydjango · Mar 11, 2013 at 01:25 PM
You don´t need a rigidbody for this. Why don´t you ad a box collider, check "is Trigger" an try it this way? Box Colliders are better for performance.
Thanks for the answer, this wasn't actually the problem. The problem was that I had the collider's size to 0!
Answer by hakermania · Mar 11, 2013 at 02:23 PM
I found the solution: My collider's size was set to (0, 0, 0) !
Follow this Question
Related Questions
Anyway to make my object not fall through the floor without convex? 0 Answers
Fast moving object not detect collision 3 Answers
Why I've a gap between meshcolliders? 0 Answers
Collisions aren't colliding all the time 0 Answers
Detect collision between kinamatic rigidbodie and gameobject without rigidbody but with colliders 0 Answers