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

Particles system end point

Discussion in 'Scripting' started by CristianKhalil, Mar 20, 2013.

  1. CristianKhalil

    CristianKhalil

    Joined:
    Feb 19, 2013
    Posts:
    9
    Hello,

    i'm new on unity and I'm trying to make particles flow from one object to another like "energy", is there a way to do that without script? or an algorithm?

    Thanks in advance
     
    Last edited: Mar 26, 2013
  2. CristianKhalil

    CristianKhalil

    Joined:
    Feb 19, 2013
    Posts:
    9
  3. Strale0

    Strale0

    Joined:
    Mar 21, 2013
    Posts:
    32
    Looktutorials on youtube :)
     
  4. CristianKhalil

    CristianKhalil

    Joined:
    Feb 19, 2013
    Posts:
    9
    I saw many tutorials but i can't find a way to create particles in one point (vector3) and they die on a end point (vector3).
    Something like this: http://vimeo.com/15037736
    but the path is just a straight line linking the point A to point B

    Thanks.
     
  5. Strale0

    Strale0

    Joined:
    Mar 21, 2013
    Posts:
    32
    BurgZergArcade on youtube
     
  6. CristianKhalil

    CristianKhalil

    Joined:
    Feb 19, 2013
    Posts:
    9
    Thanks for the replies! :D i saw this videos on youtube but i not found what i wanted
    I created this script to make the particles flow between the points like i need:

    Code (csharp):
    1.  
    2. void LateUpdate() {
    3.        
    4.         int length = particleSystem.GetParticles(particles);
    5.                 int i = 0;
    6.        
    7.         transform.LookAt(target);
    8.  
    9.         while (i < length) {
    10.            
    11.                         //Target is a Transform object
    12.             Vector3 direction = target.position - particles[i].position;
    13.             direction.Normalize();
    14.            
    15.             float variableSpeed = (particleSystem.startSpeed / (particles[i].lifetime + 0.1f)) + particles[i].startLifetime;
    16.             particles[i].position += direction * variableSpeed * Time.deltaTime;
    17.        
    18.             if(Vector3.Distance(target.position, particles[i].position) < 1.0f) {
    19.                 particles[i].lifetime = -0.1f; //Kill the particle
    20.             }
    21.            
    22.             i++;
    23.        
    24.         }
    25.  
    26.         particleSystem.SetParticles(particles, length);
    27.     }
    28.  
     
  7. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Another option is to add a plane where you want the particles to stop. Then enable collision on your particle system and drag the plane into the planes list. Finally set the lifetime loss high enough so it ends the particle life at that point. Or you could set the min/max kill speed.

    When your effect happens you can move the plane to the point you want your particles to end. Make sure the particles have a enough life time and/or speed to make it to your end point.
     
  8. jethrogillgren

    jethrogillgren

    Joined:
    Jan 11, 2017
    Posts:
    28
    For future visitors, I eventually found a very good free unity asset which does this. It's part of a repo with several other great tools. It supports multiple points, and smoothing of the path. https://github.com/BLINDED-AM-ME/UnityAssets