Search Unity

Particle System Randomize Direction, unwanted Z-axis randomizing

Discussion in 'General Graphics' started by djfrail, Jul 28, 2021.

  1. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    I’m making a particle effect using the Unity Particle System and am hoping to find a way to get more control over the RandomizeDirection feature. The game is 2D isometric and the particle effect happens in the XY axis, but RandomizeDirection also randomizes the Z axis and I need the particles to stay on the Z axis I originally assign them.

    Any ideas on how to prevent particles from changing their Z value? Is there maybe a way in scripting to get at the particle emitter and prevent it from there?

    Thanks for any help/ideas!
     
  2. april_4_short

    april_4_short

    Joined:
    Jul 19, 2021
    Posts:
    489
    You can get at the particles, with Burst control, all particles (somewhere in the API) and there's some kind of vertex processing thing... too...

    But before going down that route, what shape are you using to emit the particles?

    If it's a 3D shape (like cone or cube) then it's going to randomise directions in 3D space, by default. If you use a 2D shape (like a circle) and keep it facing the direction of the particle system, you can ensure 2D randomisation of directions.
     
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Does setting the z scale within the shape module to zero solve this issue?
     
  4. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Using a circle
     
  5. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Yes it does! Thanks!
     
    richardkettlewell likes this.
  6. StevenTillson02

    StevenTillson02

    Joined:
    Jun 30, 2021
    Posts:
    11
    By default, a 3D form (such as a cone or a cube) will randomise directions in 3D space. You may guarantee 2D randomization of directions by using a 2D shape (such as a circle) and keeping it towards the direction of the particle system.
     
    april_4_short likes this.
  7. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    True until you use randomize direction. But Richard’s fix works.
     
    richardkettlewell likes this.