Impact CFX Main Page Index API Reference Change Logs
Legacy Impact Comparison Conversion From Legacy Impact
Impact CFX Project Settings Impact Tags Logging Impact Material Registry
Impact CFX Manager Material Mapping Managing Registered Materials
Impact Materials
Audio Effect Audio Source Prefab Audio Effect Processor Particle Effect Particle System Prefab Particle Effect Processor Decal Effect Decal Prefab Decal Effect Processor URP & HDRP Decals VFX Batch Effect VFX Batch Master Creating a Visual Effect VFX Batch Effect Processor Managing Attached Effects
Impact Objects Impact Object Single Material Impact Object Rigidbody Impact Object Rigidbody (Cheap) Impact Object Custom Velocity Objects With Multiple Materials Impact Terrain
Impact Triggers Common Trigger Properties Material Count Impact Collision Trigger Impact Slide and Roll Trigger Impact Speculative Collision Trigger Impact Simple Collision Trigger Impact Particle Collision Trigger Impact On Trigger Enter Impact On Trigger Stay
Impact Raycasting
FMOD Integration Wwise Integration Master Audio Integration
Custom Triggers Custom Objects Creating an Impact Object Script Impact Material Processors Custom Effects Impact Effect Authoring Asset Effect Result Effect Data Impact Effect Processors Impact Simple Effect Processor Impact Pooled Effect Processor Pooled Effect Object Pooled Effect Authoring Pooled Effect Result Pooled Effect Data Object Pool Pooled Effect Processor Add to Impact CFX Manager Example Effect Download

Managing Attached Effects

Since effects can be parented to objects as a means of attaching them, special care must be taken when managing the pooled effect objects. When an object with effects attached to it gets destroyed, we don't want the effects attached to it to be destroyed as well. This is what the Impact Attached Effect Manager component is for.

Any object that an effect attaches to needs an Impact Attached Effect Manager component. This script is responsible for keeping track of all of the effects attached to an object. If the object does not already have this component, it will be automatically added. However, you can manually add the component yourself by going to Add Component > Impact CFX > Impact Attached Effect Manager. You have some flexibility as to where you can add this component. For example, if you have a character or a ragdoll that will recieve decals, you can add the Impact Attached Effect Manager component to the root of the character, rather than adding a component to each part of the armature.

The Impact Attached Effect Manager also has a small API you can use if you need to manually manage attached effects. Most notable is the ReleaseAllAttachedEffects method, which will release all effects attached to the object and return them to their object pools.

public void DestroyObjectExample(GameObject go)
{
	//Release all effects before destroying the object.
	if(go.TryGetComponent(out ImpactAttachedEffectManager impactAttachedEffectManager))
	{
		impactAttachedEffectManager.ReleaseAllAttachedEffects();
	}

	//Now you can safely destroy the object.
	Destroy(go)
}

If the object is destroyed, the Impact Attached Effect Manager will automatically move all of the attached effects back into their pools so that they are not also destroyed. However, this does not work on scene load and the effects will still be destroyed. If this happens, the effect object pools will automatically re-instantiate the destroyed effects on scene load. If you want to avoid re-creating effects, it is a good idea to reset all effects back to their object pools before you load a scene. To do this, you can call the ResetAllEffectProcessors on ImpactCFXGlobal or ImpactCFXManager

public void LoadSceneExample(int sceneIndex)
{
	//Reset all effects before loading the new scene.
	//This will ensure that any attached effects will be returned to their object pools, preventing them from being destroyed.
	ImpactCFXGlobal.ResetAllEffectProcessors()

	//Now you can safely load the scene.
	SceneManager.LoadScene(sceneIndex);
}