- Home /
Problem with colliding instances of same object
I want to check if object's instance is overlapping with another instance (any spawned object with another spawned object, not necessary the same object). I'm doing this by detecting collisions between bodies. But I have a problem. Spawned object (instances) are detecting collision with everything but other spawned objects. I've checked collision layers etc. All of spawned objects have rigidbodies and mesh colliders. Also when I attach my script to another body and I touch that body with an instanced object it detects collision. So problem is visible only in collision between spawned objects.
void OnCollisionEnter(Collision collision) {
if (true) {
// foreach (Transform child in this.transform) {
// if (child.name == "Cylinder") {
//collided = true;
Color c;
c = this.renderer.material.color;
c.g = 0f;
c.b = 1f;
c.r = 0f;
this.renderer.material.color = c;
Debug.Log (collision.collider.name);
//}
}
//}
foreach (ContactPoint contact in collision.contacts) {
Debug.DrawRay(contact.point, contact.normal, Color.red,15f);
}
}
objects are not collided on start. tried with that method no differences
Answer by kubas0707 · Aug 18, 2014 at 09:28 PM
Turning on convex mesh fixed the problem. I have done it by script, because after importing object from blender there is no check box allownig to do this.
Your answer
Follow this Question
Related Questions
How can I instantiate rigid bodies on top of each other without them exploding away? 2 Answers
Resume movement of instanced object relative to the original after instantiation. 2 Answers
dont instantiate clones 1 Answer
OnCollisionEnter is slow... 2 Answers
OnCollisionEnter not triggering when two rigidbody collide via Instantiate 1 Answer