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

Flipping Particle Systems

Discussion in 'General Graphics' started by FeastSC2, Nov 13, 2017.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I want to flip my particle systems from right to left depending on which direction my characters are attacking. For normal gameObjects scaling X *= -1 does the trick.

    However, inverting the scale for Particle Systems doesn't work because they have other variables like Rotation Over Lifetime which have set directions (positive/negative).
    So I must also flip those attributes, how can I do this? Or is there even a better way to flip particles? Because I know that's not the only module I'll end up using in Particle Systems.

    https://i.imgur.com/rKzJPOq.gifv

    Unity_2017-11-13_21-39-21.png

    I tried doing this through code but somehow accessing Particle Systems is always difficult for some reason.

    Code (CSharp):
    1. Ps.Stop(); // Cannot set duration whilst particle system is playing
    2.  
    3. var rotationOverLifetime = Ps.rotationOverLifetime;
    4. var yRotConstant = rotationOverLifetime.y.constant;
    5. yRotConstant *= -1; // I must reassign this value to the Particle System, but how?
    6.  
    7. Ps.Play();
     
    Beacom likes this.
  2. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    SOLUTION: Rotating the Particle System works. Don't know why I didn't test that before!
     
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
    Great :) FYI you can make particles spin the other way by setting Randomize Rotation to 1. (Maybe we should rename that one to Flip Rotation instead...)
     
    alecfilios, theANMATOR2b and FeastSC2 like this.
  4. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Good to know, thanks Richard.
    Yes that might be a better name, why is it called randomize anyway?

    I don't necessarily need this right now but I'm just curious:
    - Is everything in a ParticleSystem modifiable at runtime?
    - and how would I go about modifying that kind of value in a ParticleSystem ?

     
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
    FeastSC2 likes this.
  6. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    @FeastSC2 There is this vector 3 that is accessible via script. I've been using it recently.

    @richardkettlewell

    Code (CSharp):
    1.         ParticleSystemRenderer _tmpA = _obj.GetComponent<ParticleSystemRenderer>();
    2.         if (!facingRight)
    3.         {
    4.             _tmpA.flip = new Vector3(0, 0, 0);
    5. }
     

    Attached Files:

    • Flip.jpg
      Flip.jpg
      File size:
      29.4 KB
      Views:
      897
    Last edited: Feb 14, 2019
  7. JeremyLvChy

    JeremyLvChy

    Joined:
    Jul 23, 2019
    Posts:
    10
    no use
     
  8. JeremyLvChy

    JeremyLvChy

    Joined:
    Jul 23, 2019
    Posts:
    10
    I just set one gameobject x= -1 , it mirrored success,but how to mirror particle system ??
    ParticleSystemRenderer.flip can not flip success,such as i set ss.flip = new Vector(1,0,0),or new Vector(1,1,0) or Vector(1,1,1) ,how to set flip successfully ??
     
  9. JeremyLvChy

    JeremyLvChy

    Joined:
    Jul 23, 2019
    Posts:
    10
    Does this randomize rotation changed to particlesystemrender.flip ???
    after i set one gameobject.x = -1,how to set this flip to the particles attached to this gameobject ?