Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How do I handle shape/emitter rotation?

Discussion in 'Visual Effect Graph' started by Azeew, Sep 28, 2021.

  1. Azeew

    Azeew

    Joined:
    Jul 11, 2021
    Posts:
    49
    Hey! I'm having some trouble handling the rotation of a VFX based around a circle shape.

    I have this slash effect:
    upload_2021-9-28_19-10-41.png

    And I wanna add these particles to it:
    upload_2021-9-28_19-11-16.png

    But the slash is horizontal, and so should be the effect, while the spark particles are vertical. I just need to rotate the sparks then, right? But I just can't find a way to do that.

    The particles use a circle shape to draw it's position and then use some logic in their direction to get velocity in the direction of the circle's tangent. So while I can get my position, do some rotation with Rotate 3D and rotate the particles with that, the velocity is now going the wrong way. Do the rotation first! Couldn't get it to work. Convert the velocity into something to fit the rotation! Couldn't get it to work. Maybe I'm just incompetent, but I tried a lot and I just can't find a way to rotate the whole thing.

    Another thing I could do is to make the sparks as a completely separate VFX Graph. Is this good practice, by the way? Anyway, it seemed like a good idea - I just need to rotate the object itself and it works perfectly. But then how do I synchronize these separate pieces? It's not like in the Particle System where the children VFX will play with the parent. So maybe I'm missing something, but this separation seemed like a bad idea.

    And that's it, I'm so lost. It's the simplest thing in the world, but I have no idea how to fix this. Any help would be highly appreciated. Thanks a lot!
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,291
    Shapes cannot be rotated yet (I think 2021 can), so you must do it manually. From your description this is what you need:
    https://forum.unity.com/threads/how-do-you-rotate-the-spawn-position-of-a-particle-system.837388/

    However, shapes (circle in your case) set not only the position, but also the direction attribute, so you would need to rotate them separately. Remember to apply velocity from direction after transforms.
    In case you used other method to find velocity, you would need to post your graph layout, but the rotation idea should be very similar regardless of the approach.
    Also have in mind, that if you use local space, maybe you could just rotate main slash instead of particles, but this is solution for super lazy people :D

    Separtion in general is ok, but its worse in case of performence, it depends how many graphs you have on scene, for example 100 graphs with 4 systems inside will perform better than 400 graphs with 1 system. Update calls are faster, plus graphs are not batched currently in any way from what I know. Still, this would matter if you had many graphs on scene, not just 5 or 10.
     
    Marie_G and Azeew like this.
  3. Azeew

    Azeew

    Joined:
    Jul 11, 2021
    Posts:
    49
    Thanks a lot!! That worked pretty well. Here's what I did in the end in case someone is interested:
    upload_2021-9-30_10-21-24.png

    Cheers!