Game Lion
Game Lion

Reputation: 71

Unity OnParticleTrigger() get Collider it collides with

I wanted to make a shot with a particle system and if one of the particles collides with something, then the opponent should get damage. I use the trigger function because I want the particles to continue flying after colliding. And in case you are wondering why I don't use a raycast: if I work with a raycast, the opponent gets harm without the particles arriving.

My Code:

private void OnParticleTrigger()
    {
        if (!hitObjects.Contains(other.gameObject))
        {
            other.GetComponent<IDamageable>().GetDamage(PlayerScript.instance.damage);
            hitObjects.Add(other.gameObject);
        }
    }

where I would like to have the opponent's collider later, I have already inserted "other"

Upvotes: 0

Views: 1506

Answers (1)

asaf92
asaf92

Reputation: 1855

Make the projectile a game object with a child particle system that gets triggered once the projectile hits a target

Upvotes: 0

Related Questions