- Home /
Collider isn't working ?
I've got 2 colliders one of them is Sphere and one of them is Box collider as you can see here;
I've written this code for detecting interaction
function OnCollisionEnter(theCollision : Collision){
if (theCollision.gameObject.name == "Sphere"){
}
Debug.Log("Blue");
}
Score Controller carries the code, They are not set as trigger (both of them) score controler is Children of a prefab. What did i done wrong ?
Answer by AngryBurritoCoder · Sep 11, 2014 at 11:13 PM
one of the collider/Trigger object has to have a rigidbody component attached to it, otherwise those functions dont work p.s you can set the rigidbody to isKinematic only to make it not mess up your collisions
Answer by divasraj · Oct 08, 2021 at 05:40 PM
If you have already have rigidbody2d attached to object but then also it does not work then set rigidbody2d to dynamic and gravityscale to 0 and it should work.