Search Unity

"Look At" block in UpdateParticle throws Error

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

  1. xXPancakeXx

    xXPancakeXx

    Joined:
    Mar 14, 2015
    Posts:
    34
    Hello,

    im trying to get the angles of the looking direction using the "Look At" block, but this block doesnt seem to work on the GPU. This is what I connected when the following error shows up in the console. Do you guys know how to make it work or do I have to make my own "Look At"?
    Thanks in advance for any help.


    upload_2021-9-22_11-38-53.png


    Code (CSharp):
    1. vfx_projectilesCurved : Exception while compiling expression graph: System.InvalidOperationException: The expression UnityEditor.VFX.VFXExpressionExtractAnglesFromMatrix is not valid as it have the invalid flag: InvalidOnGPU, PerElement
    2.   at UnityEditor.VFX.VFXExpressionGraph.BuildMapper (UnityEditor.VFX.VFXContext context, System.Collections.Generic.Dictionary`2[TKey,TValue] dictionnary, UnityEditor.VFX.VFXDeviceTarget target)
    3.  
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    442
    Hi @xXPancakeXx ,

    I don't think the matrix-to-euler operation to get the angles is available on the GPU. Depending on what you are trying to do, there are a few options:

    The simplest option is to just make particles face the velocity, and then use Add Angle if you needed to orient them slightly differently:


    This will give you something like this:


    You can also subtract the old and current position, normalize it, and then use that as a orientation vector. It might not be quite what you like because it's possible that position == oldPosition in which case you'll produce a zero vector.


    Other things you can explore is setting the axes manually or using the other orient blocks.
    If you have a scenario that won't work with these options, please share it :)
     

    Attached Files:

  3. xXPancakeXx

    xXPancakeXx

    Joined:
    Mar 14, 2015
    Posts:
    34
    Oh thanks for the different approaches, did not think at all about the orient block.
    Although I went for the custom route via my own angles calculation, this are very neat ways you presented.

    But it would be good if you guys could document where some functions can be used or at least provide a proper error message.
     
  4. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    442
    Yup, completely agree; we have an error feedback system that can pop a little notification next to the thing which doesn't work or works in an unexpected ways and are slowly populating this with scenario-specific warnings. Will make sure we add this scenario as well to it, thanks for bringing it up!
     
unityunity