"Look At" block in UpdateParticle throws Error

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.

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
  at UnityEditor.VFX.VFXExpressionGraph.BuildMapper (UnityEditor.VFX.VFXContext context, System.Collections.Generic.Dictionary`2[TKey,TValue] dictionnary, UnityEditor.VFX.VFXDeviceTarget target)

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 :slight_smile:


7521008--927953--kj4Jud2bT1.gif
7521008--927956--upload_2021-9-24_23-40-32.png

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.

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!

Could I see a quick example of what LookAt angles would actually be used for? Thanks!

I’m looking into something similar to what LookRotation would do without having to use Orient. I’ve gotten close with getting Rad2Deg and Set Angle but not close enough with the normalized target position.

This is the formula I’m looking to convert
Quaternion.LookRotation(Vector3.forward, dir.normalized) * Quaternion.Euler(0, 0, Mathf.Rad2Deg * p)

8109536--1050164--upload_2022-5-7_23-22-18.png