Surz
Surz

Reputation: 1014

Unity 3D: Collision detection between target and sphere not working (3d),Collision between target and sphere not working

So I've gone through all the similar questions, but have still been unable to make this work. I'm new and getting the hang of collision detection.

I have a sphere prefab and a target prefab. The spheres are being shot at the target. When the sphere collides with the target I want the target (a 3d game object) to get destroyed.

My sphere prefab currently has a sphere collider with isTrigger checked and a rigid body that uses gravity. My target prefab has a box collider with isTrigger unchecked and a rigid body with use gravity and isKinematic unchecked (since I want the targets to just sit on the screen, not fall down).

This is my code on the sphere's script:

 void OnCollisionEnter(Collision collisionInfo) {
     Debug.Log("Detected collision between " + gameObject.name + " and " + collisionInfo.collider.name);
 }
 void OnTriggerEnter(Collider other) {
     Debug.Log("Collided with " + other.gameObject.name);
 }

Neither debug statement is printing out. Any ideas what I'm doing wrong in the editor?

Upvotes: 1

Views: 1700

Answers (1)

pasotee
pasotee

Reputation: 348

Take a look at this, it might help you a lot ! Colliedr matrix

Upvotes: 1

Related Questions