Search Unity

Stop particles update once they stop

Discussion in 'Visual Effect Graph' started by martialpotron, Sep 22, 2021.

  1. martialpotron

    martialpotron

    Joined:
    Sep 10, 2021
    Posts:
    2
    Hello, I hope you are doing great :)

    I do have an emitter that spawns physicked particles which collide with their environment.
    Once they collide and stop (due to tamping), I'd like to keep them alive but not active anymore (for obvious performances reasons :))

    Do you guys have any idea about a possible solution to reach that result ?

    Thank you very much ! Have a great day
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Hello, can you provide just a bit more details?
    For example whats the difference (or meaning) between active and alive? and what is that performance reason?
     
  3. martialpotron

    martialpotron

    Joined:
    Sep 10, 2021
    Posts:
    2
    Hello,

    Simple example, I shoot at a wall, destroy it, spawns dozens of bricks that fly, collide with the ground, and roll a bit.
    Those bricks then stabilize, and should never have to move again.

    I'd like to make sure they are not moving at all, and if possible, not doing unnecessary gravity/collision tests

    have a great day
     
  4. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hey @martialpotron ,

    Currently, you'd do this via some logic (i.e. get the particle velocity's magnitude and set gravity to 0 when it's under some threshold).

    We have a task for adding boolean ports to blocks, which will allow you to toggle the logic itself (i.e. use the same velocity example we discussed, but then turn off the gravity block off altogether as opposed to setting it to 0).
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Actually reading the question above reminded me something - I might want to change state of particles, but just once in certain frame, for example:
    • I might want to kill some particles or particles inside certain zone
    • There is additional wind or explosion force to apply (velocity change)
    • I need to change attribute of any particle, but just once per few seconds
    Currently I could add Kill Sphere block in update or anything similar and just change its position and size for given frame, but it would be more handy to call some method and execute operation on all particles once. In first case this operation is called every frame, but maybe performence impact is negligible?
    I guess when boolean ports get introduced it will be easier to do something like this by enabling bool for one frame.

    Anyway, I do not know if this is actually any usefull, but what I propose is something like adding possibility to execute block of code by calling some method of vfx graph.
    Code (CSharp):
    1. // instructions are scheduled to be called before vfx update
    2. visualEffect.ExecuteBlock( somethingContainingInstructions );
     
  6. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Yup, this scenarios should also be covered by the boolean ports to blocks feature. Depending on how it gets implemented, it can look something like this:

    (Mockup, the actual implementation might differ)

    Then you'd be able to directly do a
    myVfx.SetBool("MyExposedBool", desiredState);
    to toggle whole behaviors.
     

    Attached Files: