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 smooth emit over time/distance using velocity only

Discussion in 'Visual Effect Graph' started by Trivium_NickHubben, Apr 14, 2023.

  1. Trivium_NickHubben

    Trivium_NickHubben

    Joined:
    Jul 28, 2021
    Posts:
    4
    Trying to create a "pyro" stage effect, and wondering if i'm approaching the right/wrong way. I'm ending up with 'groups' of particles instead of emitting smoothly. Screen Shot 2023-04-14 at 10.16.50 AM.png

    The 'position' of the particle isn't really moving, i'm 'firing' the lead glowing particle upwards and using GPU events to spawn the sparks. I've tried Trigger Event Rate with distance and time, and they look the same.

    I've read this thread
    https://forum.unity.com/threads/how...ystem-spawning-behavior.1166027/#post-7476496

    and am only gathering that i could use tweens to 'fire' the projectile instead of upwards velocity, therefore setting the current position and last frame position to LERP between the positions, but I'd love to find a different way.

    TYIA
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Hello.
    With fast movement, spawning can appear to be "choppy". This is in part due to the fact there's "too much movement" between two frames. So increasing the spawnRate won't really help.
    What can be done instead is to store the "Previous Position" (previous frame position) and interpolate between the previous and current frame.

    In the Setup that I'm sharing, the "Lead particles" system is storing the "Current Position" in an attribute (oldPosition). This is done before the velocity integration (Moving position due to velocity) by the Update Context.
    upload_2023-4-19_9-11-10.png

    To spawn particles, I'm using a "Trigger Event Always" that will fire every frame.

    If I get the "Source position" of the lead particle and use it directly to set the position of the Child particles, as said earlier, we can see a stepping effect.
    Unity_o7nD7yqbOS.gif

    upload_2023-4-19_9-34-16.png



    So, as we have stored the Position before velocity integration in the "oldPosition" attribute, we can interpolate between the "Source oldPosition" and "Source Position". And to interpolate and random values between 0-1 will do the trick:
    upload_2023-4-19_9-35-6.png
    Unity_IXbf4IgaEX.gif
    Instead of using a Random, you can use the SpawnIndex attribute. As we're using a Trigger Event Always, all particles are spawn on the same frame in a burst fashion. This mean that each frame, this index will be between 0- and the Count number set in the trigger event.

    With this in mind, we can use it to interpolate our position.
     
    Trivium_NickHubben likes this.
  3. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    upload_2023-4-19_9-46-7.png


    upload_2023-4-19_9-46-21.png

    Hope this post will help you.I'm including a small package so that you can take a look.
    Have a nice day.
     

    Attached Files:

    Trivium_NickHubben likes this.
  4. Trivium_NickHubben

    Trivium_NickHubben

    Joined:
    Jul 28, 2021
    Posts:
    4
    @OrsonFavrel apologies for only just seeing this - and thank you for the package and explanation! Cheers!
     
  5. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    No worries. Hope it helped. Have a great day.