A ground slash attack vfx implemented with a Mesh, decal textures, VFX Graph and some programming. Made in Unity Unity 2021.3.10f1
- 3D Mesh for the Slash
- Ground Decals
- First Person Character Controller
- Adjust Dynamically to Terrain
- Debris
Ground Spash VFX by Gabriel Aguiar
-
Project configuration
- Use the Universal Render Pipeline.
- Use VFX Graph.
-
Mesh for the Slash
- Create the Mesh in Blender.
- Start with a Bezier curve, extrude it to create a 3D shape
- Map the UVs for the gradient texture.
- Open the UV editor.
- Constrain to Image Bounds.
- Map the UVs to be able to use a simple gradient to cover the shape.
- Export as .fbx to include the UVs mapping.
- Create the Mesh in Blender.
-
VFX Graph for the Slash
- Burst of 1 single particle.
- We won't make the particle have a velocity, it will just grow in place.
NOTE: We will move the whole VFX object and make it spawn other particles as it moves (decals and debris)
- Use an Output Particle Mesh node.
- Set culling mode to both, so it renders all sides of the mesh.
- Rotate and adjust until the mesh faces the right direction.
- Use the "Soft Particle" setting so that Unity fades the particle when it touches other geometry.
- Set lifetime to 2 seconds, also can make this a parameter.
- Make the mesh grow over time.
- Set a color and intensity.
-
Gradient Texture
- Use any graphics software to create a gradient texture.
- Make a gradient left-to-righ, from zero to full opacity.
- In Unity set the "Wrap Mode" to clamp, to avoid artifacts in the transparent side.
- In the Output Particle Mesh node.
- Set the gradient texture.
-
Ground Decals
- Create a secondary system.
- In the Spawn System node.
- Use the Spawn Over Distance component, to spawn particles as the VFX itself moves.
- Connect a Change Space node to it, using "Target Space" World.
- This means the VFX will detect a change of the position of the VFX, and that will trigger an event to emit particles.
- But particles will move along with the whole VFX, so we need to fix that.
- In the Initialize Particle node.
- Change it to World instead of Local, so particles stay where they are spawned and don't stick to the VFX.
- Set position of particles to (0,0,0) but using Local so it matches the position of the VFX, (otherwise they'd be spawned at the zero position of the world)
- Use an Output Particle Forward Decal node.
- Use a default particle texture.
- Rotate, set color, accordingly.
- Create two output decals, one black and another orange, to simulate burn.
-
Programming
- First Person Character Controller
- Integrate the starter asset in your project.
- Add a character controller in the scene.
- Shooter
- Create a component that insantiates a GameObject for the VFX.
- Orients the projectile.
- Sets a velocity to the rigid body.
- Projectile
- Decreases its speed over time, to eventually stop.
- Casts a Ray into the ground to snap itself to the geometry.
- First Person Character Controller
-
Debris
- Model the meshes of the debris in Blender.
- VFX Graph for the Debris
- Reuse the same system used for the decals, maybe make the decals a sub graph.
- Use an Output Particle URP Lit Mesh node.
- This is important, so decals apply to the debris meshes.
- Set random colors between a range.
- Set random size and rotations.
- Set size over life for the debris to shrink and dissapear.
- In the Initialize Particle node.
- Set random local velocity to make the particles go in every direction.
- In the Update Particle node.
- Add gravity to the particles.
- Add a colission with plane, to make them stop at the ground.
- Set another particle system to spawn debris at the position of the VFX. To conceal the limitations of the collissions with geometry of the debris.