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. Dismiss Notice

[SOLVED]Particle help

Discussion in 'General Graphics' started by LaliKinux, May 20, 2016.

  1. LaliKinux

    LaliKinux

    Joined:
    Apr 26, 2016
    Posts:
    38
    Sorry if this is in the wrong section.

    Anyways,

    So I just completed the Roll-A-Ball tut.
    Now I'm trying to add particle effects on the pickups.

    The problem is.. I cant get anything to work. I've tried looking this up but I can't find anything that works?..

    Heres my code which is suppose to activate it every time the player collides, however this isn't giving me any results..

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ParticleEmitter : MonoBehaviour
    5. {
    6.     public ParticleSystem exp;
    7.  
    8.     void OnTriggerEnter (Collider col)
    9.     {
    10.         if (col.gameObject.CompareTag ("Player"))
    11.         {
    12.             Debug.Log (" I should be emitting paritcles");
    13.             Explode ();
    14.         }
    15.     }
    16.  
    17.     void Explode()
    18.     {
    19.         exp = GetComponent<ParticleSystem> ();
    20.         exp.Play ();
    21.  
    22.     }
    23. }
    24.  
    Warning:
    I have a particle system on ever pickup. I tried making it so it spawns the particle effect on that pick up with instantiate, however that wouldn't work either.
    I even tried making the particles massive just in case it was too small. And yes, I've hit "Apply" every time I put something on one of the pickups. The pickups are all under 1 prefab, just as in the tut.

    Can someone please help me? This is very frustrating, I feel like it's a lot easier than what I'm making it out to be
     
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    Is there a ParticleSystem on the same GameObject as ParticleEmitter?

    Here's a basic instantiate script that works:

    Code (csharp):
    1. public GameObject _particlePrefab;
    2.  
    3. void OnTriggerEnter(Collider collider)
    4. {
    5.     if (collider.tag != "Player") return;
    6.        
    7.     Instantiate(_particlePrefab, transform.position, Quaternion.identity);
    8. }
     
  3. LaliKinux

    LaliKinux

    Joined:
    Apr 26, 2016
    Posts:
    38
    Hmm still not working.. It's spawning them, but the particles aren't appearing?..
    Here's the updated code that is attached to the pickups:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Particles : MonoBehaviour
    5. {
    6.     public GameObject deathParticles;
    7.  
    8.     void OnTriggerEnter(Collider col)
    9.     {
    10.         if (col.tag != "Player")
    11.             {
    12.                 return;
    13.             }
    14.  
    15.         Instantiate (deathParticles, transform.position, Quaternion.identity);
    16.     }
    17.  
    18.  
    19.  
    20.  
    21.  
    22. }
    23.  
    See attachments below for a picture of unity..
     

    Attached Files:

  4. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    Do you have Play On Awake ticked in the ParticleSystem?
     
    richardkettlewell likes this.
  5. LaliKinux

    LaliKinux

    Joined:
    Apr 26, 2016
    Posts:
    38
    I'm 99% sure I don't. (At work right now).

    Is it suppose to be ticked for cases like this?
     
  6. LaliKinux

    LaliKinux

    Joined:
    Apr 26, 2016
    Posts:
    38
    That worked!
     
    richardkettlewell likes this.