Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

how come my particle is not being triggered?

Discussion in 'General Graphics' started by smokingbunny, Dec 16, 2014.

  1. smokingbunny

    smokingbunny

    Joined:
    Jul 24, 2014
    Posts:
    98
    hello peolpe,

    so i was working on animation deaths for some things, but have instead opted to go with unity particle effects and play with them instead.
    but im just having a bitch of a time getting my particle effect to even play when i collide with say an enemy

    ive created a simple emitter just now just so i can get things to work first, then move on with all the other heavier things, but the emitter doesnt kick in at all when the enemy is touched or even when it reaches its death stage

    now here is my current code for the bad guy, which has the Transform set to the particle system.
    Code (csharp):
    1.  
    2. public class EnemyCircleHealth : MonoBehaviour {
    3.    public int circleHealth = 2;
    4.    public int circleHealthScore = 10;
    5.    public Transform explosion;
    6.  
    7.    void Update () {
    8.       if(circleHealth <= 0){
    9.          Destroy(this.gameObject);
    10.          ScoreManager.score += circleHealthScore;
    11.        }
    12.       if(circleHealth > 2){
    13.          circleHealth = 2;
    14.        }
    15.     }
    16.  
    17.    void OnCollisionEnter2D(Collision2D enemyCollide){
    18.       if(enemyCollide.gameObject.tag == "Enemy"){
    19.          circleHealth -= 1;
    20.          Instantiate(explosion, transform.position, transform.rotation);
    21.          audio.Play();
    22.        }
    23.    }
    24. }
    25.  
    now i have tried moving all the code away that makes the explosion/particle death to a 'OnTriggerEnter2D' but that just isnt working. even doing really simple, but nothing.
    im just a bit stuck because nothing is actually working to get the particle to emit.
    i was following a brackeys tutorial and have messed with it further because that also did not work

    thanks to anyone who can shed some light
     
  2. smokingbunny

    smokingbunny

    Joined:
    Jul 24, 2014
    Posts:
    98
    anyone? I'm still stuck with this

    thanks
     
  3. eiVix

    eiVix

    Joined:
    Dec 3, 2012
    Posts:
    29
    Have you placed your particle in the Resources folder?
     
  4. smokingbunny

    smokingbunny

    Joined:
    Jul 24, 2014
    Posts:
    98
    oooh, nope. to be honest i didn't realise that things would be specific that much. ill have a go

    thanks
     
  5. smokingbunny

    smokingbunny

    Joined:
    Jul 24, 2014
    Posts:
    98
    for some insane reason its working now, even without moving my prefab particle to Resources. i tested for both folder locations, both came up with the same result. i don't know what it is , but its exactly the same as it was. very strange indeed
     
  6. eiVix

    eiVix

    Joined:
    Dec 3, 2012
    Posts:
    29
    Weird, all I know is that if you are going to instantiate a gameobject you must place it first in the Resources folder, at least for me it never worked the other way around. :) Glad you've got it working
     
  7. smokingbunny

    smokingbunny

    Joined:
    Jul 24, 2014
    Posts:
    98
    well i dose a bit moe digging around and messing with it. seems that particles CANT be multiple levels in folders. seem that it can be in one level but no more. resources can be used as and when but notspecificaly

    thanks
     
  8. smokingbunny

    smokingbunny

    Joined:
    Jul 24, 2014
    Posts:
    98
    im still getting used to unitys way f working. ive come more frm the cod based side and falder depth was never a problem unless you coud not remember the names when typing them in to call images or assets ;)

    thanks