[simple question] Get Skeletal Mesh?

How do I retrieve the USkeletalMesh from the USkeletalMeshComponent? I can’t find it anywhere I must be overlooking it somewhere. I also checked USkeletalMeshComponent | Unreal Engine Documentation and various other sites but couldn’t find it. I would have expected it to be called GetSkeletalMesh() but it doesn’t exist. I do know that it seems to be located inside FAnimationEvaluationContext but that variable is also private now.

header

UPROPERTY(BlueprintReadWrite, VisibleAnywhere, Category = "BaseItem")
UStaticMeshComponent* StaticMeshComp;

UPROPERTY(BlueprintReadWrite, VisibleAnywhere, Category = "BaseItem")
USkeletalMeshComponent* SkeletalMeshComp;

cpp

if (StaticMeshComp->StaticMesh != nullptr) { return StaticMeshComp; } // no longer works
if (StaticMeshComp->GetStaticMesh() != nullptr) { return StaticMeshComp; } // works (probably changed in the last 3 patches somewhere)
if (SkeletalMeshComp->SkeletalMesh != nullptr) { return SkeletalMeshComp; } // no longer works in UE 4.18 How to retrieve it now? EDIT: This however still works.

simple question but there is no simple answer, I was trying to track it down for you but I really can’t find a way to access it!

The skeletal mesh value is actually stored in USkinnedMeshComponent, although not specifically declared as such it is public as the GENERATED_UCLASS_BODY() adds a public declaration in it’s macro magic - the newer version of this macro GENERATED_BODY() does not do this.

class ENGINE_API USkinnedMeshComponent : public UMeshComponent
{
	GENERATED_UCLASS_BODY()

	/** The skeletal mesh used by this component. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Mesh")
	class USkeletalMesh* SkeletalMesh;

I was able to compile this code fine

USkeletalMeshComponent* Comp = nullptr;
check(Comp->SkeletalMesh);
1 Like

so that TWeakObjectPtr< class USkinnedMeshComponent > MasterPoseComponent; under the declaration of SkeletalMesh is also public?
Is there a place to check the difference of those macros?.

The macros can be found in the corresponding .generated.h file, search for GENERATED_BODY or GENERATED_BODY_LEGACY. I don’t understand what is going on fully though

The GENERATED_BODY macro simply redirects you to one of the macros in the .generated.h file - it contains to code itself. For the definition of GENERATED_BODY look in ObjectMacros.h

hmm. this works for me:
GetMesh()->SkeletalMesh;
Note “Mesh” is private so you need to use GetMesh()

1 Like

With the latest MetaHuman, I am getting this warning message when I try to compile:

Get SkeletalMesh : Usage of ‘SkeletalMesh’ has been deprecated. Use USkeletalMeshComponent::GetSkeletalMeshAsset() or GetSkinnedAsset() instead.

How can I fix that?
Is there any step by step guide how I can use the USkeletalMeshComponent instead of the SkeletalMesh?

Thanks for any little guide,
appreciate it!

1 Like

Getting this exact same error in UE 5.1 and this was the only post I could find on this topic and with this error message. Does anyone know what the issue might be?

3 Likes

same here, anyone know what’s up?

1 Like

Have you tried “GetSkeletalMeshAsset()”?

1 Like

So this is actually throwing a warning when compiling Metahumans in 5.1 blueprints. Understood this is the programming forum, but it’s literally the only thread about this topic. Should I start one in blueprints forum? The effect it’s having is that when I choose a new skeletal mesh for (body, feet, legs, etc.) a part of my MH, the editor menu doesn’t reflect this change, even though the MH in the viewport does.

1 Like

This is probably as good a place as any - good luck!

I’m a beginner, but I found this video and it worked for me:

8 Likes

Thanks man, just starting off, too, and this helped me:)

This is really the only thread on this issue. This video helped me, thank you very much

I imported a Metahuman character into UE5.1 ,errors showed “Use USkeletalMeshComponent::GetSkeletalMeshAsset() or GetSkinnedAsset() instead.”, I saw this post, and your this reply, I searched “GetSkeletalMeshAsset” node,and set it into the blueprint,the errors disapear,but I don’t know if this behavior will influnce the progarm running normally.

Yeah, what about the ‘is editor only’ flag? It won’t work in-game?

Watch this tutorial for the solution :slightly_smiling_face:

This is the solution!!!

Thank you!