> For the complete documentation index, see [llms.txt](https://dante-3.gitbook.io/dante-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dante-3.gitbook.io/dante-docs/modular-attachment-system/modular-attachment-fragment/common-patterns.md).

# Common Patterns

### Material override fragment (child of a mesh fragment)

Create a Blueprint fragment nested under a mesh fragment. Because the system propagates the parent mesh automatically, the child can access it without knowing the exact tag:

1. **CollectSoftRefs** — declare the target material as a soft ref
2. **ApplyToComponent** — call `GetParentMeshComponent()` → cast to `UMeshComponent` → `SetMaterial(0, Material)`
3. **RemoveFromComponent** — restore the original material (or no-op)

Alternatively, from outside the hierarchy, use `Component→GetMeshComponentByFragmentTag(SomeTag)→SetMaterial(0, Material)`. This works because `GetMeshComponentByFragmentTag` returns `UMeshComponent*` — works for both static and skeletal meshes.

### Stat modifier fragment (no spawned components)

```cpp
FSpawnedFragmentData UMyStatFragment::ApplyToComponent_Implementation(UModularAttachmentComponent* Comp)
{
    FSpawnedFragmentData Data = Super::ApplyToComponent_Implementation(Comp);
    // No components to spawn — just modify a gameplay attribute
    if (UAbilitySystemComponent* ASC = Comp->GetOwner()->FindComponentByClass<UAbilitySystemComponent>())
    {
        // Apply GE or modify attribute
    }
    return Data;  // SpawnedComponents stays empty — that's fine
}
```
