Template Mismatch during attachment

Hi…

I’m trying to collect my weapon and to attach it to an socket at the right hand of my character.

pCurrentWeapon->AttachRootComponentTo( m_pEquipmentClassOwner->Mesh, FName( TEXT( "WeaponSocket" ) ), EAttachLocation::SnapToTarget );

I’m running into that error:

Ensure condition failed: false [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.5\Engine\Source\Runtime\Engine\Private\SceneComponent.cpp] [Line: 744] 
Template Mismatch during attachment. Attaching instanced component to template component. Parent 'CharacterMesh0' Self 'SphereComp'

We had a prototype project with the same lines of code and with the same BP working.
How can i change the instance to template or connect each other.

Hi, friend
I have the same problem and I haven’t find the answer,
Could you find how to fix it?
thanks!

So a “template” component refers to the class object which is used as a template or mold to create instances from. Instances are therefore the constructed objects from those templates. What you actually see in game is going to be instances. What the error is telling you is that your weapon object is an instance, but the character mesh object you are attempting to attach it to is a template.

Somehow the m_pEquipmentClassOwner variable is not pointing to the instance of your character but its template. This is going to depend on where and how you are setting that variable.

1 Like