Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to set a relative position target to an absolute position source

Discussion in 'Visual Effect Graph' started by scarscarin, Apr 7, 2021.

  1. scarscarin

    scarscarin

    Joined:
    Apr 5, 2019
    Posts:
    23
    Hi





    I was wondering if it is possible to spawn the particle system to a position that is between force attractor and original Kinect position. As of now, it seems that the system spawns back to the original Kinect UV position at each frame, creating this flickering effect.

    How do I debug this?
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @scarscarin ,

    Full disclosure, I haven't used Kinect so shooting from the hip here, take everything I say with a grain of salt :)
    Here's what might be happening:


    Update executes each frame.
    At the start of the frame you:
    1. Set the particle position
    2. Add a force to the velocity attribute, this block does velocity += (Force / mass) * deltaTime;
    3.
    At the end of each Update, there's an implicit block (Integration: Update Position) which does the following: position += velocity * deltaTime;

    So you'll set the position, then at the end of Update it will move a bit based on your force and then at the beginning of the next frame you set it back to its original place which makes it snap back, which might cause the flicker that you see.

    There might be other things with the setup, but this popped to mind. A few things you can explore:

    1. Moving your Set Position/Color/Alpha to Initialize so they are only set once, but can still independently travel with the velocity set via your force block without being re-set. You'll also need to spawn them constantly and give them a small lifetime so they expire. This might however blur your overall look.

    2. Set the position directly in Initialize Once, and then do some easing in Update like this:

    This will move the existing position from the last frame towards the new position from your Kinect based on some easing value you specify, so it could alleviate the snapping.

    You could also trying doing the movement towards the attractor in Output (without velocity, just some lerp) but you'll need some timing value (like the age of the particle) and maybe some distance checks (so they don't all move with the same speed).

    Hope any of this might be of help or at least not get in the way of finding an actual solution! :)
     

    Attached Files:

    scarscarin likes this.
  3. scarscarin

    scarscarin

    Joined:
    Apr 5, 2019
    Posts:
    23
    VladVNeykov likes this.