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. Dismiss Notice

Question How to calculate attraction force between local and world object when vfx is transformed

Discussion in 'Visual Effect Graph' started by skowronski_m, Oct 1, 2023.

  1. skowronski_m

    skowronski_m

    Joined:
    Oct 5, 2021
    Posts:
    41
    I'm currently struggling to implement a simple attractor logic when my VFX graph is placed in a rotated and scaled scene. The screenshots should illustrate the problem nicely:

    Particle spawn at (0,0,0) and should be attracted by the black sphere.

    Bildschirmfoto_2023-09-28_um_10.28.49.png
    This is the vfx graph I am using:
    Bildschirmfoto_2023-09-28_um_10.34.45.png
    When the vfx graph is not transformed, the force calculation works nicely. As soon as I transform the vfx graph, everything is off.
    Bildschirmfoto_2023-09-28_um_10.29.22.png
    Bildschirmfoto_2023-09-28_um_10.29.12.png
    Now I know why this happens, but I don't know how to fix it. Any help would be greatly appreciated :)

    Btw: I also tried going this road (transforming attractor to local, also did not work)
    Bildschirmfoto_2023-09-29_um_09.45.58.png
     
  2. Peplm

    Peplm

    Joined:
    Aug 2, 2019
    Posts:
    13
    Maybe you already found a solution. This is happening because you are using the force Node. So it will give your particle a velocity and then when going pass the target it should come back after a while. You should see it if you expand the lifetime of the Particle.

    Instead you can directly use a set velocity which should give you what you want.
     
  3. skowronski_m

    skowronski_m

    Joined:
    Oct 5, 2021
    Posts:
    41
    Thanks for the answer, but unfortunately, that does not work either. It works when having the transform local scale of the vfx at (1,1,1), but as soon as I transform it to (-1,1,1), it looks like this:

    Bildschirmfoto 2023-10-02 um 08.45.24.png
     
  4. Peplm

    Peplm

    Joined:
    Aug 2, 2019
    Posts:
    13
    If you don't want the scale to affect the effect you can pass the vfx in world space by clicking the local button in a context node. But you might have to track the origin position of the FX and set it manually. I'm not sure what behaviour you want by changing the scale of the FX.



    upload_2023-10-2_13-4-56.png
     
    Marie_G likes this.
  5. Marie_G

    Marie_G

    Unity Technologies

    Joined:
    Mar 9, 2021
    Posts:
    48
    To complete with that, you can use the "VFXProperty binder" component in the VFX game object's inspector to fetch world transform of game objects in your scene