- Home /
OnParticleCollision hitting the non-existent Collider?
There's an object, let's call it Player (tag: player) that does not have a collider attached to it. It is fully surrounded by an object, let's call it Shield (tag:defence) with a sphere collider. A particle system with a collider enabled hits the Shield. OnParticleCollision method takes gameobject as an input. When I try to get the gameobject, I get Player.
Debug.Log(other.tag);
Which is impossible. So I tried
Debug.Log(other.GetComponent<Collider>().name);
and I get an error - no collider attached!
I don't understand this (other similar objects like bullets and LineRenderers) do not have this problem:
1) Why doesn't the ParticleSystem detect Shield with a Collider attached 2) How does it detect Player WITHOUT a collider?
This is very confusing. When I click off the collider on the Shield, Player is not detected anymore.
Is this smth to do with the layer? or the particle sys rendere?
Answer by Pulov · Oct 26, 2020 at 01:51 PM
I''ve the very same issue, my only workaround its
void OnParticleCollision(GameObject collided)
{
if (collided.GetComponent<Collider>())
{}
}
ITs a whame because getcomponent so often is not the cheapest thing...