Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Using particle FX - cannot seem to get them going

Discussion in 'Scripting' started by rickcollette, Apr 23, 2014.

  1. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    First - thanks to anyone willing to help with this. No free puppies of beer for help - just a hearty "thank you very much!"

    I have been messing around with this: https://www.assetstore.unity3d.com/#/content/7891
    And trying to get particle effects to play when a cell is taken. I am using this: https://www.assetstore.unity3d.com/#/content/4010 for the FX.

    I found a few threads, tried a few things on my own.. and I just cannot seem to get the FX to show up..
    I call the convert_to_position from another script with the kit to get the x/y coords.. and try to instantiate a GameObject that is declared here:

    public GameObject destroyMagnet;

    Then I drag a particle prefab over to the inspector.
    The game "works", the CFX_ElectricMesh prefab shows as a (Clone) in the hierarchy when the function is called, then vanishes when the animation is completed.. but I never actually *see* it.

    The specific code I am using is:

    Code (csharp):
    1.  
    2.             destroyMagnet.renderer.sortingLayerName = "Foreground";
    3.             destroyMagnet.renderer.sortingOrder = 2;
    4.             Instantiate(destroyMagnet,CHelper.convert_to_position(obj),Quaternion.identity);
    5.  
    and here is the entire function:

    Code (csharp):
    1.  
    2. IEnumerator reproduce(short cell)
    3.     {
    4.         CPlayer current_player = this.players[this.current_player_index];
    5.         CPlayer other_player = this.players.Find(obj => obj.player_index != this.current_player_index);
    6.        
    7.         clear_available_attacking_cells();
    8.         yield return new WaitForSeconds(0.5f);
    9.        
    10.         this.board[cell] = current_player.player_index;
    11.         current_player.add(cell);
    12.  
    13.         yield return new WaitForSeconds(0.5f);
    14.        
    15.         // eat.
    16.         List<short> neighbors = CHelper.find_neighbor_cells(cell, other_player.cell_indexes, 1);
    17.         foreach (short obj in neighbors)
    18.         {
    19.             Debug.Log ("OBJ: " + obj);
    20.             this.board[obj] = current_player.player_index;
    21.             current_player.add(obj);
    22.             Debug.Log ("POS: " + CHelper.convert_to_position(obj));
    23.             destroyMagnet.renderer.sortingLayerName = "Foreground";
    24.             destroyMagnet.renderer.sortingOrder = 2;
    25.             Instantiate(destroyMagnet,CHelper.convert_to_position(obj),Quaternion.identity);
    26.             other_player.remove(obj);
    27.             //Destroy(destroyingParticle, 1f);
    28.             yield return new WaitForSeconds(0.2f);
    29.         }
    30.     }
    31.