- Home /
Destroy on collision wont work with mesh collider
I made a code to destroy a projectile when it collides with a collider, but it doesn't work on mesh colliders. Up until now, it has been fine because I haven't imported any models that really needed mesh colliders, but im starting to import some. This is my script, what can I do to make it detect mesh collision?
var impactexplosion : ParticleEmitter;
function OnCollisionEnter(hit : Collision) { Destroy(gameObject); Instantiate(impactexplosion,transform.position,transform.rotation); }
Answer by Lo0NuhtiK · Dec 27, 2011 at 07:32 AM
If you're using a mesh collider on the projectile AND on the target, that will probably be the cause of the problem. Try having one be mesh collider, with the other being a primitive (box,sphere,etc) collider (probably the projectile would be better this way). Or marking one of the mesh colliders as convex. See if that helps.
Your answer
Follow this Question
Related Questions
Destroying upon collision 1 Answer
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Why Can't I Destroy This Object? 4 Answers
Destroying specific clone object while not destroying others on screen 5 Answers
Checking Instantiate/Destroy has been called | Checking number of scene GameObjects 1 Answer