Enables using complex splines in combination with Unity's Visual Effect Graph to easily author effects with curves live in the Unity Editor:
spline-interaction.mp4
Sometimes you might need huge amounts of particles but want to control their flow even more precisely as you traditionally can with flow maps or other techniques.
In VFX Graph there is already a SampleBezier
node included (see here) but it is limited to just one segment and hard to handle.
Here are the easiest ways to install the package, choose either:
Open Package Manager, select "Add package from git URL..." and enter
https://github.com/krisrok/vfxpath.git
{
"dependencies": {
"com.krisrok.vfxpath": "https://github.com/krisrok/vfxpath.git",
...
https://docs.unity3d.com/Packages/[email protected]/manual/index.html
Depending on your Unity version you might need to add the dependency manually to your manifest or you can just install it via Package Manager.
Tested with 1.0.1 and 2.1.0.
https://github.com/SebLague/Path-Creator
There are several ways to install it.
There are two parts to this: Providing the spline's data to the VFX graph (via VFXPropertyBinder) and enabling access to the data inside the graphs (via custom Nodes, or better Subgraphs).
Have a look at the included Samples for some more concrete usage pointers.
In general you need to:
- Add a Visual Effect component to your GameObject
- Set or create a Visual Effect Asset configured to have the neccessary properties exposed
- Add a SplineContainer component (to the same or any other GameObject)
- Create a spline using the scene view tools
- Add a VFXPropertyBinder component to the same GameObject
- Add the Property Binding:
+
-> VfxPath/Spline - (If the SplineContainer is found on the same GameObject it will be automatically referenced, otherwise you have to manually reference it)
- (If the Visual Effect Asset's properties are named correctly it will just work, otherwise you have to manually set the names you used)
- Add the Property Binding:
Use VFXGraph's own VFXPropertyBinder and add a VFXPath property binding. There are bindings available for SplineContainer and for PathCreator, but they will only show up if you correctly installed any of the dependencies, see above.
This will create small textures containing the spline's sampled positions and rotations, just like other point caches.
The bindings will also automatically transfer some meta info about the spline's bounds and the point count to the VFX Graph.
You can increase/decrease the Point Count
to get a tighter/looser fit:
point-count.mp4
Set Draw Lines
to true to display the sampled lines like seen in the video above.
There are some subgraphs to simplify accessing and processing the spline's data to be usable.
There are a few simpler sample graphs included:
- Import the "Common Graphs" sample via Package Manager.
- Import the "Spline Scene" sample if you want to use Unity's Spline package and/or import the "PathCreator Scene" if you want to use PathCreator.
- Find and open the imported scenes below
Assets\Samples\VFX Path
- Tweak the existing splines and graphs, create your own!