Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Hitting Particle System

Discussion in 'Scripting' started by Gabimela, Jan 19, 2020.

  1. Gabimela

    Gabimela

    Joined:
    Oct 3, 2019
    Posts:
    23
    I am trying to make the player do an animation when it hits a particle system which is tagged "enemies" but it is not working. this is what i have in the player logic script:
    Code (CSharp):
    1.     void OnTriggerEnter(Collider col)
    2.     {
    3.          if (col.tag == "enemies")
    4.          {
    5.             Debug.Log("Collided with particle");
    6.             anim.SetTrigger("Hit");
    7.                
    8.  
    9.          }
    10.  
    11.     }
     
  2. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    163
  3. Gabimela

    Gabimela

    Joined:
    Oct 3, 2019
    Posts:
    23
  4. MaximumTre

    MaximumTre

    Joined:
    Nov 28, 2015
    Posts:
    163
    Not sure because I stopped using particles for collision checks a long time ago, but IIRC they don't work with triggers, you must use a Rigidbody. Make sure your layers are set up correctly, and make sure you have a collider on the player. Also make sure you actually set the tag. I forget stuff like that all the time. ;P