Unity VFX Graph: Spherical Velocity

In Valley of Shadow, we recently made a huge change to the underlying engine. We went from using standard rendering on Unity 2018 to HDRP on Unity 2019. As a result, we've been rebuilding some particle systems using VFX Graph instead of the Particle System.

One of the rebuilt VFX Graph particles is a spherical explosion of particles that quickly slows down and hangs in the air. We use it for the Force Missile spell when it hits a target. I failed to find any resources online explaining this spherical explosion effect, so I decided to make one of my own to hopefully help others out.

So, without further ado...

Spherical Velocity in VFX Graph

To create spherical velocity, there are only 2 steps:

  1. Set the position of each particle on a sphere.

  2. Set the particle’s velocity to its direction.

You can tweak each of these steps, but these will result in a functioning spherical explosion that look like the gif above.

If you are only looking for the graph, here it is. I will delve deeper into it below.

Full graph for creating a spherical particle explosion

Set the position on a sphere

When the particle is initialized, you want to place it on the surface of a sphere. You can do this by selecting the "Initialize Particle" node, pressing spacebar, and selecting "Position (Sphere)". Ensure the following:

  • Position Mode is set to "Surface". You can set this to "Volume" to spawn particles inside the sphere, rather than on its surface. This will result in a non-uniform explosion of particles, which might actually be what you want!

  • Radius is set to some small number, such as 0.1. This will ensure the explosion emanates from a single point in space, rather than appearing on a large sphere. Depending on your effect, you may actually want it to be larger than 0.1.

Node for placing the particle on the surface of a sphere

Set the particle's velocity to its direction

A particle's "direction" is, I believe, its direction from the origin (0, 0, 0), presented as a Vector3.* Thus, if a particle is on the surface of a sphere, its direction will be pointing outward from the sphere's center. To create spherical velocity, then, all we have to do is set the velocity to the particle's direction, like so:

Nodes for converting particle’s direction to its velocity

Note that this should also be done in the Initialize Particle node, after the Position (Sphere) has been set. If this is done before the Position (Sphere) is done, the direction will not have been calculated yet!

You're done

And that's it, with those 3 simple nodes you have an exploding sphere of particles. It's not complex, but it did take me a lot of digging and experimenting to figure out. I hope to save others that time!

If you want the full graph that created the gif shown at the beginning of this post, you can find it here.


*I was unable to find "direction" in the documentation, so if someone can find it or list a better definition, please do and I will update this.