Getting component by name

Try with GetDefaultSubobjectByName

Example:

UCameraComponent* ThirdPersonPlayerCamera = Cast(GetCharacterOwner()->GetDefaultSubobjectByName(TEXT(“FollowCamera”)));

GetDefaultSubobjectByName is a function embeded in all UObject classes and lets you get a pointer to an object whose name you know and search for in the TEXT(“objectname”) parameter…

In your case

UMeshComponent * MyMesh = Cast(GetDefaultSubobjectByName(TEXT(“Mesh”)));

hope this helps!

7 Likes