Search Unity

Disable pivot on particle quad when looking at position

Discussion in 'Visual Effect Graph' started by GamertagYoureIt, Jun 22, 2022.

  1. GamertagYoureIt

    GamertagYoureIt

    Joined:
    Oct 27, 2017
    Posts:
    9
    I've got a set of particle quads spawning along the surface of a sphere. I'd like for them to all face the center of the sphere (which in this case is world origin (0, 0, 0)).

    The issue I'm encountering is when I move the camera, the pivot of each quad moves to match the camera. Is there a way to disable this? I'd like for the particles to just be frozen in place.

    I'm not sure if I need to lock the Z rotation somehow or if there's a different method I should be using.

    Orient: Look at Position is the closest functionality I can get, but there must be a way to turn off the pivot shifting...

    Any suggestions would be helpful. I'm using HDRP if it makes any difference.

    (I tried uploading a picture of the graph but it looks like imgr uploads appear as broken links?)

     
    Last edited: Jun 22, 2022
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    When you spawn from Position: Sphere it sets direction attribute by default, so you can use this as face direction of the particle. If you call orient in output or update they are updated every frame (towards new position), so instead don't do that and set everything in initialize and never touch again.
     
  3. GamertagYoureIt

    GamertagYoureIt

    Joined:
    Oct 27, 2017
    Posts:
    9
    Thanks for the reply. If I disable the Orient block entirely, the positions of the particles are correct but their direction all faces towards one axis rather than the center.

    Since Imgur uploading wasn't working for me, I tried to take a gif instead.



    Here's the graph. I've got a random Z angle because I do want an initial random rotation, but to your point, I would like to set it and forget it rather than having it update each frame... Just wasn't sure how to tell it to face a position from the initial spawn, particularly because the particles aren't intended to move or disappear after initial spawn.



    I'm using it to spawn cloud textures to create the illusion of surrounding clouds, if that helps...
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Well, I am not actually sure if there is simple math to get euler angles from direction, maybe atan2, but angles are probably applied in order, so I am not sure it would work.
    However there is no reason to make your life harder, so just use orient block, but with custom target. In case of sphere it can be it's center, but to make it more generic it should be along the direction.
    upload_2022-6-23_1-3-31.png

    Orient is not actually rotating angles, instead it "rotates" particle space axes. If for whatever reason (performence?) you would need to do this in the initialization context, then this is what orient does under the hood:
    upload_2022-6-23_1-6-7.png
    * this is for "along velocity"

    Actually setting axes (by orient) is better anyway as you can still rotate particles relative to their plane.
     
  5. GamertagYoureIt

    GamertagYoureIt

    Joined:
    Oct 27, 2017
    Posts:
    9
    Not sure if I misunderstood the instructions but I'm still getting the same effect. Here's what I've got for the Output block:

     
  6. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    This is strange. I guess you are overriding or not writing direction at all, or your object i misplaced or something like that (something to do with L & W). Check sphere inspector, there must be dropdown with direction set to override.

    If you can't make it work, then try from scratch - create new default system, remove velocity block and add position: sphere, then add orient in the same way you already did.