- Home /
Collision between capsule and sphere colliders does not work
I am trying to detect a collision between a capsule collider and a sphere collider with this code but it does not work.
void OnCollisionEnter(Collision other)
{
if (other.transform.tag == "fprojectile")
{
Debug.Log("Success");
}
}
What's wrong and how can I fix it?
I'm going to need a bit more info. What scripts are you using to make the capsule collider and sphere collider move? If you are using transform.position or transform.translate the collision won't happen.
No. The collision will indeed happen if you use transform.position or transform.Translate, assu$$anonymous$$g it's possible for collision to happen at all. (See my answer about using a rigidbody.)
Answer by Eric5h5 · Aug 01, 2014 at 04:19 AM
See the docs for OnCollisionEnter, specifically the part that mentions a non-kinematic rigidbody. You would of course also need the colliding object to have a tag that exactly matches what you have in the script.
P.S. You should ideally use CompareTag instead of using string comparisons.