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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

World-space system inheriting velocity of game object?

Discussion in 'Visual Effect Graph' started by dgoyette, Jun 1, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,959
    I'm making a moving object that should leave particles behind it as it moves. I've set the system to World, which causes it to leave the particles behind, but I haven't found a way for them to inherit the velocity of the VFX graph which is moving. Ideally it would inherit the velocity, but some drag would slow it down. I tried adding a block to inherit source velocity, but this doesn't seem to do anything.

    I'm starting with a default "Swarm Particle System", and I have a simple script to move the VFX Graph game object. Can anyone suggest an approach to having particles inherit the velocity of the system at the moment they're initialized?
     
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    280
    Hi, at the moment you have to do it manually by exposing a property to pass the velocity to the graph (typically the gradient of the position of the object)
     
    dgoyette likes this.
  3. kayronjm

    kayronjm

    Joined:
    Jun 15, 2019
    Posts:
    34
    I'm having a similar problem with this and that doesn't seem to work either.

    upload_2020-6-14_0-43-45.png

    I'm just trying to get the particles shot out to use the weapon turret's current velocity (this exposed Vector3 is set by C# code prior to triggering the start event) and then add the random velocity locally.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,959
    The approach that JulienF mentioned worked fine for me. I similarly have a Vector3 property on the VFX graph, which I use just like you use, except that for mine it's set to world velocity, not local velocity as you have it:

    upload_2020-6-13_21-11-27.png

    Then I just the velocity in code:

    Code (CSharp):
    1. vfxSystem.SetVector3(VisualEffectConstants.PreRift.SystemVelocityParameter, Velocity);
    2. vfxSystem.Play();
    3.  
    Seems to work fine for me. Make sure you're not having issues with Local vs World.
     
  5. kayronjm

    kayronjm

    Joined:
    Jun 15, 2019
    Posts:
    34
    Thanks for that! I tried setting velocity in World as well as Local but neither seem to work OK. Perhaps it's the velocity vector I'm setting that's the issue. I had set it to the velocity vector of the weapon turret carrying the VFX graph in it so it made sense to me. Maybe it's also the fact that I'm adding a random local velocity to it. I don't know really.
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,959
    If you're adding more velocity, that should be fine. But if you're ever "setting" the velocity, that will step over this, so you shouldn't be setting the velocity more than once.
     
  7. kayronjm

    kayronjm

    Joined:
    Jun 15, 2019
    Posts:
    34
    Thanks, yeah, I understand that. I managed to get it working as expected. The particles were dragging behind too much for my liking but it was my fault - I had Drag values set too high. :p Turns out for my use-case, it looks better to just keep everything local anyway, but at least with this thread, I've learned how to sort this out for other use-cases. Thank you.
     
  8. Delacroz

    Delacroz

    Joined:
    Sep 23, 2019
    Posts:
    13
    Hey, can you please tell me how you did to leave particles behind it as it moves? thanks!
     
  9. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,959
    It's subtle, but within the nodes of the graph you'll see a small button you can toggle between World and Local. Usually you just need to make sure the rendering is done in World, to prevent the particles from moving along with the moving system.
     
  10. Delacroz

    Delacroz

    Joined:
    Sep 23, 2019
    Posts:
    13
    thanks!
     
unityunity