# Template Mismatch during attachment. Attaching instanced component to template component

**URL:** <https://forums.unrealengine.com/t/template-mismatch-during-attachment-attaching-instanced-component-to-template-component/1865353>\
**Category:** C++\
**Tags:** c-c, c-class-wizard, c-and-bluepri, c-custommeshcomponen, c-and-blueprint, c-error, c-class, c-custom-shape, c-programming, c-cone-shape, unreal-engine, CPP, Blueprint, question\
**Created:** [May 20, 2024, 8:45pm UTC](https://forums.unrealengine.com/t/template-mismatch-during-attachment-attaching-instanced-component-to-template-component/1865353 "2024-05-20T20:45:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![DrTrev4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrTrev4](https://forums.unrealengine.com/u/DrTrev4)\
**Post date:** [May 25, 2024, 7:20pm UTC](https://forums.unrealengine.com/t/template-mismatch-during-attachment-attaching-instanced-component-to-template-component/1865353/2 "2024-05-25T19:20:43Z")

</div>

Try this: [https://forums.unrealengine.com/t/ue5-template-mismatch-during-attaching-of-instanced-component/1510733/2](https://forums.unrealengine.com/t/ue5-template-mismatch-during-attaching-of-instanced-component/1510733/2)

I had a custom SceneComponent that would break when a Blueprint inherited from a Blueprint that had my component. I was able to fix it by following that thread.

I wanted to attach a couple StaticMeshComponent to my custom SceneComponent.

Constructor:  
StaticMeshComponent1-\>SetupAttachment(this);  
StaticMeshComponent0-\>SetupAttachment(this);

OnRegister:  
Super::OnRegister();  
this-\>StaticMesh1-\>AttachToComponent(this, FAttachmentRules::KeepRelativeTransform);  
this-\>StaticMesh0-\>AttachToComponent(this, FAttachmentRules::KeepRelativeTransorm);

---

_[View the full topic](https://forums.unrealengine.com/t/template-mismatch-during-attachment-attaching-instanced-component-to-template-component/1865353)._
