x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

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).

Persona

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).

UEEditor

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. :)

Product Version: UE 4.19
Tags:
more ▼

asked May 17 '18 at 07:40 AM in C++ Programming

avatar image

robhuem
1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

more ▼

answered May 22 '18 at 08:20 AM

avatar image

robhuem
1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question