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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Spawn particles in circle

Discussion in 'Visual Effect Graph' started by densheka, Sep 12, 2022.

  1. densheka

    densheka

    Joined:
    Oct 7, 2020
    Posts:
    2
    Hi, currently studying how to create vfx in vfx graph and haver a question about declaring position of particles
    I have a position in shape of circle, but the question is how to spawn particles along the arc not randomly, but with declared step, for example 0.05.
    And the second question is how to rotate each particle depending of position of arc where it spawned
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128

    Hello.

    So regarding the "Circle Position" with declared steps you have several way of doing it.
    The easiest way might be to use a "Set Position: Sequential Circle" instead of the "Arc Circle".
    This Block Allow you to use the "ParticleID" to "loop" over the Circle Position.
    Set it's Mode to "Wrap" and your Count to desired value (it will be the your number of Steps) and don't forget to balance your Particle Count with the desired "Steps" :

    upload_2022-9-12_23-46-5.png

    The other way would be to use the Regular "Set position : Arc Sphere" Block taht you already use and set it's "SpawnMode" to "Custom".
    You'll then have access to the "Arc Sequencer", a 0-1 pin input that control the position on the circle.
    You'll have to provide a 0-1 value in "steps". Here are some ideas:

    The "particleID" attribute Modulo (%) the Number of desired Steps will giving you a "cycling" integer value between
    0 and the desired numberSteps.
    In my example ParticleID % 20 will give us a int Value between 0-19.
    We then divide this value by the Desired Steps and this would give use a 0-1 value to use for or "Arc Sequencer".

    upload_2022-9-12_23-56-0.png
    Another method could be to generate a "Random Number" Between 0- NumberSteps, Floor it to get rid of decimal part, and divide it by the Number of Steps. This will also give you a 0-1 "stepped value" usable in the "Arc Sequencer".
    But as the it's a random generation, sometime some Spot might not be filled by a particle.
    It really depend on your end Goal.
     

    Attached Files:

    densheka likes this.
  3. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Regarding the "Rotation Question" it really depends on what you really want to achieve.
    You could take a "Position" based approach were you directly set the "Particle Position". For this the "Rotate2D" or "Rotate3d" block operator will be your best friends:
    Here's a small ScreenShot using "Rotate2D" if you only need a "simple" 2Drotation.
    upload_2022-9-13_0-37-1.png

    But don't hesitate to look at this thread for more in-depth info as it's quite similar to what you're asking.

    A different approach can be taken by setting the "Velocity" of our particles instead of the "Position". This approach is more "physical" so you'll be able to add Turbulence, Drag an other Forces.
    The Downside is that it's less "Art directable" and can be harder to control.
    But here are some ideas:

    You need Velocity vector that rotate around your "Circle Front Axis". While there're many ways to achieve this , here are two of them:


    Cross Product:
    A cross product between two vectors, is an operation that will return another Vector perpendicular two both the input Vectors. With this in Mind:
    upload_2022-9-13_0-19-0.png

    Here are some Arrows to Help you Visualize the Resulting Vector:
    upload_2022-9-13_0-37-33.png

    Another Method would be to Swap-Inverted Vector Components.
    The ParticlePosition on a (0,0,0) centered Circle can be used as the "Normal" of this circle.
    So we can swap two component of our vector to Obtain another Vector.
    From there Inverting the Axes Should give us a result pretty similar to our Cross-Product.

    upload_2022-9-13_0-31-29.png

    And here are Some Vector To help you visualize the Swapping operation and the the "X" Inversion.
    upload_2022-9-13_0-34-47.png
     
    densheka likes this.
  4. densheka

    densheka

    Joined:
    Oct 7, 2020
    Posts:
    2
    Thanks a lot, really appreciate your detailed response, it really helped me.
     
  5. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Glad it helped .
    Have a great day.