skip to Main Content

Adding Trails FX To Your Scene

For regular gameobjects, the object you add Trail Effect must have a MeshFilter component on it. For characters, make sure Trail FX is added to a Skinned Mesh Renderer.

These are the options exposed by Trail Effect component:

Trail Effect component settings

  • Profile: you can create a profile asset with reusable settings for other Trail Effect instances in the scene. Click the “Create” button to automatically create a new profile asset and copy the current settings into it. Then you can just drag & drop the newly create profile asset into another Trail Effect component.
  • Target: usually, Trail Effect effects are added to the same object to which it’s added but you can also specify a different target (gameobject) here.
  • Execute In Edit Mode: enabling this setting will show the effects while not in play mode.

Triggers

This section let you configure the moment where a “snapshot” or stamp is added to the trail. A snapshot captures the object position, rotation and scale (and in the case of skinned mesh renderers, their vertices as well).

  • Active: means that the object is leaving trails.
  • Ignore First Frames: avoids leaving trails during certain frames at the start (since Trail Effect component is enabled).
  • Continuous: enable this option to add a snapshot every frame.
  • World Position Change: enable this option to add a snapshot when the object moves certain distance in world space.
  • Screen Position Change: enable this option to add a snapshot when the object moves certain pixels in the screen.
  • Time Interval: enable this option to add a snapshot every certain time interval.
  • Collisions: enable this option to add a snapshot when the object collides with other objects.

Appearance

This is the most important section and let you customize the look of the effect:

  • Trail Effect: selects the type of effect. Each type provides different look and options.
  • Color Ramp: enable this section to customize the pattern of the trail in the Color type effect. Additional options include the color ramp texture and two anchors that define the axis along which the texture is mapped. This effect works great for swords: create two empty gameobjects as children of the sword. One of these gameobjects will represent the start of the blade and the other, the tip of the blade. The color ramp texture will map those colors to the edge of the sword.

You can find 2 sample color ramp textures in the SamplePresets folder.

  • Color Sequence: specifies how or when the system will pick a color for the Color effect. You can specify different styles:
  • Color Over Time: tints the color of the trail as it’s generated. Note that colors combine with other colors. If you want to preserve the color over time value, keep the Color Sequence to Fixed and white color.
  • Fade Out: fades (makes transparent) the trail as it’s left behind. If disabled, the trail will keep it’s alpha for the entire length.
  • Duration: duration of the trail.
  • Max Steps Per Frame: maximum number of interpolations per frame (or maximum number of snapshots per frame). Objects moving fast may require a higher value for this setting. Also check the “Interpolate” setting in the Skinned Mesh section.
  • Steps Buffer Size: length of the snapshot buffer. Snapshots are stored in a circular buffer which should hold enough capacity so all snapshots generated during the “Duration” interval can be kept.
  • Draw Behind: renders the trail behind the character. This technique uses stencil buffer.
  • Cull Mode: culling mode of the snapshot rendering. Note that snapshots are copies of the geometry of the object or character.
  • SubMesh Mask: in case of multi-mesh objects, which one should be used to render trails. The mask is compared with the submesh number in a bitwise fashion. For example, a mask value of 3 will include submeshes 1 and 2.
  • Position: this section let you customize the offset for the snapshot location when it’s generated (this value is added to the original object position).
  • Scale: let you customize how the scale of the snapshot changes along the trail.

Skinned Mesh Only

Options for skinned mesh renderers:

  • Use Last Animation: enable this option to force all snapshots in the trail to use the same state of the animated vertices.
  • Max Batches: maximum number of batches that can be sent to the GPU. Skinned objects require a different batch per snapshot unless the “Use Last Animation”option is enabled.
  • Interpolate: this option interpolates vertices in the trail effect shaders to provide a smoother result. This option works best with “Continuous” option in the Appearance section. Use both to provide the smoothest trails for animated characters or skinned objects.
  • Animation States: enter the name of the animation states for which you want the trails to appear. You can specify several names separated by comma, for example “Attack, Jump”. Additionally, you can specify a time interval per each animation state to limit the trails to that time interval, example: Attack(0.3-0.7). In this case, the trail will be generated only when the character is attacking and during the 0.3-0.7 seconds interval of the attack animation.
  • Animator: reference to the animator component that drives the animation.
Back To Top