Search Unity

Resolved Skinned Mesh Sampling, position offset

Discussion in 'Visual Effect Graph' started by Kimproductions, May 13, 2022.

  1. Kimproductions

    Kimproductions

    Joined:
    Feb 28, 2018
    Posts:
    6
    I decided to make my own post since I still couldn't figure it out. I was following this https://forum.unity.com/threads/skinned-mesh-sampling.1084166/#post-6990500 post on skinned mesh sampling with the VFX graph in URP.

    Everything works great except that I need the VFX to be a child of the RobotKyle gameobject so I can spawn it around the world, destroy it, etc.


    However, whenever I move it into Robot Kyle's hierarchy, the position is offset in a strange way.

    I assume this is because the VFX graph is also using it's own position when using the setposition node so it's kind of doubling the position.


    Is there any way to parent the VFX graph to Robot Kyle without causing this offset?

    What I've tried:
    I have tried to subtract the object's position right before the setposition node, which works for the position, except the rotation doesn't follow, but I don't know how to subtract rotation.

    Thank you,

    Isaac
     
  2. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    154
    Hello,

    If I understand correctly, your VFX system is in Local space and the Visual Effect component belongs to the Skinned Mesh Hierarchy, your are also applying the transform through the VFX Property Binder.

    Thus, what you are observing is the translation of the root bone applied twice.
    You have to choose between these two workarounds, either:
    - Remove the Transform from Position Binder
    - Move the visual effect component back in root hierarchy

    If you look back at this sample the chosen solution was to have the Visual Effect Component in root hierarchy.
    If you need the VFX to be a child of the RobotKyle gameobject", then, it's probably more convenient to move the the VFX (assuming the system is still in Local Space) as child of the root bone (named ribs) insuring the VisualEffect component transform is identity.
    upload_2022-5-13_12-4-2.png

    We are aware this workflow isn't ideal, we are improving this feature in 2022.2.a14 (not yet available), here an early preview (it explains the new settings field with Position Mesh in my previous screenshot):
    _2022_a_14.gif
    The Position Mesh & Sample Mesh operator will directly include an option to integrate the root bone transform. You can also compose with an additional transform.

    More information and documentation will soon be available.
     
    Last edited: May 13, 2022
  3. Kimproductions

    Kimproductions

    Joined:
    Feb 28, 2018
    Posts:
    6

    Wow that worked!!! Thank you so much! I've been working on this problem for over 40 hours and it was as simple as putting the particles under the root bone and turning off the VFX binder. Additionally, since I wanted the particles to trail off in world space, I moved the position nodes into initialize particle and changed it to world space.

    Thank you once again, you're a life saver.

    -Isaac
     
  4. Ofenkatze

    Ofenkatze

    Joined:
    Aug 14, 2013
    Posts:
    15
    Same setup here: I have a graph that I need to be a child of the mesh it's using as emitter source - but I also need it to be in world space. Is there any workaround for that?

    Edit: I was dumb. It's really as simple as Kimproduction wrote: parent your graph under the root bone, turn off any position binding, set any positioning in the graph in initialize, set graph to world.
     
    Last edited: Sep 13, 2023
  5. angeldevelopment

    angeldevelopment

    Joined:
    Sep 28, 2022
    Posts:
    247
    Im having the same issue, Im not sure what im doing wrong. I have the transform of my vfx graph as identity
     

    Attached Files:

  6. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    194
    Hello. From the look at your screenshot, you have a more recent Unity version. The Set Position Skinned mesh block has been updated and now has the option to apply either the World root transform or Local Root transform.
    In your case, it's applying the world root transform, so you don't need to wire the transform properties in the transform slot.
    You can take a look at this forum post where I've shared a small VFX package with a simple World Space system to attach to a Character skeleton.
    Have a lovely day.
     
    Marie_G likes this.