# Actor with UPoseableMeshComponent does not have a SkeletalMesh inside it's Constructor

**URL:** <https://forums.unrealengine.com/t/actor-with-uposeablemeshcomponent-does-not-have-a-skeletalmesh-inside-its-constructor/425308>\
**Category:** Character & Animation\
**Tags:** poseable-mesh, unreal-engine, Scripting, skeletalmesh, question\
**Created:** [May 17, 2018, 7:40am UTC](https://forums.unrealengine.com/t/actor-with-uposeablemeshcomponent-does-not-have-a-skeletalmesh-inside-its-constructor/425308 "2018-05-17T07:40:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_21a11bcb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_21a11bcb](https://forums.unrealengine.com/u/anonymous_user_21a11bcb)\
**Post date:** [May 17, 2018, 7:40am UTC](https://forums.unrealengine.com/t/actor-with-uposeablemeshcomponent-does-not-have-a-skeletalmesh-inside-its-constructor/425308/1 "2018-05-17T07:40:05Z")

</div>

Hello,

I tried to get access to the **SkeletalMesh** during the constructor of a **UPoseableMeshComponent** (3rd Person Project with Starter Content).

To drag and drop different instances of an Actor with that Component inside the World, I created a blueprint called BP\_CustomActor from the C+±Class **MyPoseableMeshComponent** (for _source_ see below) and set the parent of that BP to **AActor** (see [Picture01][1]).

 ![241286-personaskeletalmeshnotbeingassigned.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/a/9/fa9e82a0aab7abe0148815b744b6c7e6e11a20cd.jpeg)

Then I tried to drag and drop the **SkeletalMesh** from the Content folder to the SkeletalMesh of the **MyPoseableMeshComponent** (indicated by the pink arrow in [Picture02][3]).

 ![241285-skeletalmeshnotbeingassigned.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/c/8/cc819e4e3630d1f163a346ae970457a7572a0f83.jpeg)

Immediately UE called the Constructor of it:

> ## LogSkeletalMesh: Warning:
> 
> LogSkeletalMesh: Warning: Inside of  
> UMyPoseableMeshComponent-Constructor!  
> LogSkeletalMesh: Warning: Number of  
> bones: 0
> 
> LogSkeletalMesh: Warning:  
> m\_pSkeletalMesh NOT set …
> 
> LogSkeletalMesh: Warning: END OF  
> UMyPoseableMeshComponent  
> CONSTRUCTOR!!!

It is saying that the **SkeletalMesh** which is accessible through **USkinnedMeshComponent** is not being set, although I assigned it through UE-Editor.

What am I doing wrong here?

Although I assigned the **SkeletalMesh** the membervariables _m\_pSkeletalMesh_ and _m\_pSkeleton_ aren’t set either during construction. Shouldn’t they get updated to the SkeletalMesh you set in the **UE-Editor**?

* * *

For additional information on the MyPoseableMeshComponent:

:::::::::::::::::: MyPoseableMeshComponent.h ::::::::::::::::::

```
/**
 *
 */
UCLASS(ClassGroup = Rendering, config = Engine, editinlinenew, meta = (BlueprintSpawnableComponent))
class SKELETONLOGGING_API UMyPoseableMeshComponent
	:
		public UPoseableMeshComponent
{
	GENERATED_BODY()

public:
	UMyPoseableMeshComponent();

	UPROPERTY(VisibleAnywhere, Category = ATEST)
		class USkeleton* m_pSkeleton;

	UPROPERTY(VisibleAnywhere, Category = ATEST)
		class USkeletalMesh* m_pSkeletalMesh;

};

```

:::::::::::::::::: MyPoseableMeshComponent.h ::::::::::::::::::

```
#include "MyPoseableMeshComponent.h"
#include "Animation/Skeleton.h"
#include "Engine/SkeletalMesh.h"
#include "Components/SkeletalMeshComponent.h"

UMyPoseableMeshComponent::UMyPoseableMeshComponent()
{ 
	UE_LOG(LogSkeletalMesh, Warning, 
		TEXT("-----------------------------------------------------------"));
	UE_LOG(LogSkeletalMesh, Warning, 
		TEXT("Inside of UMyPoseableMeshComponent-Constructor!"));
	UE_LOG(LogSkeletalMesh, Warning, 
		TEXT("Number of bones: %d"), this->GetNumBones());
	this->SetBoneRotationByName("spine_01", 
		FRotator(45, 45, 45), EBoneSpaces::WorldSpace);	 

	 
	m_pSkeletalMesh = this->SkeletalMesh;
	if (m_pSkeletalMesh) {
		UE_LOG(LogSkeletalMesh, Warning, 
			TEXT("m_pSkeletalMesh set :D"));

		m_pSkeleton = m_pSkeletalMesh->Skeleton;
		if (m_pSkeleton) { 
			UE_LOG(LogSkeletalMesh, Warning, 
				TEXT("m_pSkeleton set :D"));
		} 
		else
		{
			UE_LOG(LogSkeletalMesh, Warning, 
				TEXT("m_pSkeleton NOT set ....."));
		}
	}
	else
	{
		UE_LOG(LogSkeletalMesh, Warning, 
			TEXT("m_pSkeletalMesh NOT set ....."));
	}

	UE_LOG(LogSkeletalMesh, Warning, 
		TEXT("END OF UMyPoseableMeshComponent CONSTRUCTOR!!!"));
} 

```

* * *

If there is any information missing or not fully described, I will try to provide or correct them. 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_21a11bcb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_21a11bcb](https://forums.unrealengine.com/u/anonymous_user_21a11bcb)\
**Post date:** [May 22, 2018, 8:20am UTC](https://forums.unrealengine.com/t/actor-with-uposeablemeshcomponent-does-not-have-a-skeletalmesh-inside-its-constructor/425308/2 "2018-05-22T08:20:26Z")

</div>

Ok I found out that reason for it being not set in the Constructor of the class **MyPoseableMeshComponent** :

The values set by the **UE-Editor** aren’t passed along inside the Constructor. I always thought something magically appeared beforehand, that already set the member **m\_pSkeletalMesh** which is visible to the editor by the macro _UPROPERTY(VisibleAnywhere, Category = ATEST)_. The member is set somewhere after in time.

- Not sure when that happens though.  
Would be nice to know.

To improve my code so the member is updated and set on construction I added the code:

```
#if WITH_EDITOR
void UMyPoseableMeshComponent::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
	UE_LOG(LogSkeletalMesh, Warning, TEXT("UMyPoseableMeshComponent::PostEditChangeProperty(...)"));

	if (m_pAltMeshAsset) {
		UE_LOG(LogSkeletalMesh, Warning, TEXT("set SkeletalMesh to the one set in UE-Editor :D"));
		this->SetSkeletalMesh(m_pAltMeshAsset, true);
	}
	else {
		UE_LOG(LogSkeletalMesh, Warning, TEXT("The SkeletalMesh set in UE-Editor is NULL :("));

	}

	Super::PostEditChangeProperty(PropertyChangedEvent);	// triggers completly new construction of this!
}
#endif

```

which basically is called when a property on this object has been modified externally (e.g. by UE-Editor). And also called the constructor of UMyPoseableMeshComponent again.Not sure whether that’s how you would do it. If someone has a better solution to it, don’t hesitate to provide your solution.

Something else I found out. The UE-Editor assignments aren’t set after calling **PostInitProperties** and **PostLoad**

```
void UMyPoseableMeshComponent::PostInitProperties()
{
	UE_LOG(LogSkeletalMesh, Warning, TEXT("PostInitProperties start: UMyPoseableMeshComponent (called after constructor)"));
	Super::PostInitProperties();
	// no UE_editor properties being assigned to this component yet
}

void UMyPoseableMeshComponent::PostLoad()
{
	UE_LOG(LogSkeletalMesh, Warning, TEXT("UMyPoseableMeshComponent::PostLoad()"));
	Super::PostLoad();
	// no UE_editor properties being assigned to this component yet
}

```

similar questions:

- [Behavior asset assigned from editor is null in c++ class - Programming & Scripting - Epic Developer Community Forums](https://answers.unrealengine.com/questions/226172/behavior-asset-assigned-from-editor-is-null-in-c-c.html)
