# How do you attach a skeletal mesh to an empty character on event play?

**URL:** <https://forums.unrealengine.com/t/how-do-you-attach-a-skeletal-mesh-to-an-empty-character-on-event-play/283675>\
**Category:** Character & Animation\
**Tags:** unreal-engine, CPP, question\
**Created:** [May 18, 2014, 7:10pm UTC](https://forums.unrealengine.com/t/how-do-you-attach-a-skeletal-mesh-to-an-empty-character-on-event-play/283675 "2014-05-18T19:10:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shoiko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shoiko](https://forums.unrealengine.com/u/Shoiko)\
**Post date:** [May 18, 2014, 7:10pm UTC](https://forums.unrealengine.com/t/how-do-you-attach-a-skeletal-mesh-to-an-empty-character-on-event-play/283675/1 "2014-05-18T19:10:10Z")

</div>

I’ve look through the fourms and the answer page but I can’t get the examples that they all explain to work.

```
enter code here
USkeletalMesh* ARPGParty::getPlayerMesh(int32 index){

	long asd = index;
	if (PartyMemberCount <= index){
		////Con::warnf("WARNING::Party Index out of range: %d", index);
		return nullptr;
	}
															  //SkeletalMesh'/Game/RPGEngine/Actors/Characters/TheWarrior/TWar_Actor.TWar_Actor'
															  //mesh(*(PartyMembers[index].DataBlock));
	static ConstructorHelpers::FObjectFinder<USkeletalMesh> mesh(TEXT("SkeletalMesh'/Game/RPGEngine/Actors/Characters/TheWarrior/TWar_Actor.TWar_Actor'"));// );
	return mesh.Object;
}

```

This is what I am using to get the mesh via string saved in a database listing and create my party members on event play. But this fails every time. Even when I copy reference directly from the content browser the constructor fails.

All I want to do basically is to dynamically create the controller mesh and apply the animation when the level starts. But blueprint can’t create a mesh with a dynamic string so i tried this method and it fails on the creation of the mesh.

The break is on: \> UE4Editor-RPGEngine\_ProtoType-Win64-DebugGame.dll!ConstructorHelpers::FObjectFinder::FObjectFinder(const wchar\_t \* ObjectToFind) Line 67 C++

---

<div class="post-metadata">

**Author:** ![Shoiko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shoiko](https://forums.unrealengine.com/u/Shoiko)\
**Post date:** [May 21, 2014, 11:03am UTC](https://forums.unrealengine.com/t/how-do-you-attach-a-skeletal-mesh-to-an-empty-character-on-event-play/283675/2 "2014-05-21T11:03:07Z")

</div>

Via Rama:

```
template <typename ObjClass>
static FORCEINLINE ObjClass* LoadObjFromPathPTR(const FName& Path)
{
	if (Path == NAME_None) return NULL;
	//~

	return Cast<ObjClass>(StaticLoadObject(ObjClass::StaticClass(), NULL, *Path.ToString()));
}

USkeletalMesh* ARPGParty::getPlayerMesh(int32 index){

	long asd = index;
	if (PartyMemberCount <= index){
		////Con::warnf("WARNING::Party Index out of range: %d", index);
		return nullptr;
	}

	FName name = *PartyMembers[index].DataBlock;
	USkeletalMesh* LoadedObject = LoadObjFromPathPTR<USkeletalMesh>(name);//load the object as per tutorial below or use static load object directly, or use ObjectFinder.

	
	if (LoadedObject)
	{
		return LoadedObject;
	}
	return nullptr;
}

```

Source:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
