I’m trying to fix that but i’m sure that i’m doing something wrong, but i dont know what is.
I build a quick space game… both my ‘rock’ and ‘bullet’ has Rigidbody and MeshCollider and thuis script:
using UnityEngine;
using System.Collections;
public class CollisionClass : MonoBehaviour {
void Start() {
collider.isTrigger = true;
}
void Update() {}
void OnTriggerEnter(Collider other) {
Debug.Log("Hit!!!");
Destroy(other.gameObject);
}
void OnCollisionEnter(Collision collision) {
Debug.Log("Hit!!!");
}
}
and both have this properties (Image - attach):
Am i doing something wrong? because when the bullet passes through the rock, no debug message comes in console.
Mesh colliders need to be set to “Convex” in order to collide with other mesh colliders.
Note that mesh colliders, especially the convex mesh colliders, are quite performance intense. Try to approximate the mesh’s shape with primitive colliders instead.
This is what you are looking at and what I meant talking about approximation.
In a nutshell: Add extra gameObjects to your main gameObject’s hierarchy, and add primitive collider types to those. They will be “summed up” to compound colliders which are way cheaper in terms of performance than convex mesh colliders. Plus convex mesh colliders are limited to 255 tris only.