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"

[C++] Possible Bug? Inherited UStaticMeshComponent looses Mesh on Blueprint Compile when attached through different class then the Actor itself.

Hey everybody,

I have a problem with a disappearing mesh:

I created a simple Actor:

MyActor.h

 UCLASS()
 class VRBASEFRAMEWORK_API AMyActor : public AActor
 {
     GENERATED_BODY()
     
 public:    
     // Sets default values for this actor's properties
     AMyActor();
 
 protected:
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
 
 public:    
     // Called every frame
     virtual void Tick(float DeltaTime) override;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     UStaticMeshComponent* ActorMesh;        
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     class UMySceneComponent* ChildScene;
 };

MyActor.cpp

 // Sets default values
 AMyActor::AMyActor()
 {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     ActorMesh= CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ActorMesh"));
     RootComponent = ActorMesh;
 
     ChildScene = CreateDefaultSubobject<UMySceneComponent>(TEXT("ChildScene"));
     ChildScene->SetupAttachment(ActorMesh);
 }
 
 // Called when the game starts or when spawned
 void AMyActor::BeginPlay()
 {
     Super::BeginPlay();
 }
 
 // Called every frame
 void AMyActor::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 }

In the constructor i attached a custom scene component which also contains a mesh:

MySceneComponent.h

 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class VRBASEFRAMEWORK_API UMySceneComponent : public USceneComponent
 {
     GENERATED_BODY()
 
 public:    
     // Sets default values for this component's properties
     UMySceneComponent();
 
 protected:
     // Called when the game starts
     virtual void BeginPlay() override;
 
 public:    
     // Called every frame
     virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
     
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     UStaticMeshComponent* ChildMesh;            
 };

MySceneComponent.cpp

 // Sets default values for this component's properties
 UMySceneComponent::UMySceneComponent()
 {
     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
     // off to improve performance if you don't need them.
     PrimaryComponentTick.bCanEverTick = true;
 
     ChildMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Child));
     ChildMesh->SetupAttachment(this);
 }
 
 
 // Called when the game starts
 void UMySceneComponent::BeginPlay()
 {
     Super::BeginPlay();
 }
 
 
 // Called every frame
 void UMySceneComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
 {
     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
 }

Then i created a Blueprint which is based on the MyActor class. In the Blueprint i set the StaticMesh for both the ActorMesh and ChildMesh. alt text When i compile the Blueprint now the ChildMesh disappears and i don't know why that is. alt text Things i've noticed is that when I click on ChildMesh (Inherited) in the Components Panel the Details Panel is totally empty. When i click on ActorMesh (Inherited) I can see the Static Mesh Components variables. Also the StaticMesh is still set in the Details Panel, but it doesn't show up in the viewport. Dragging the Actor into a map doesn't work as well. Another thing is that i can drag the ActorMesh into the EventGraph and get a Get or Set Node. If i drag the ChildMesh into the Event Graph it gives the following error: Cannot find correspondig variable (make sure component has been assigned to one). alt text

I really hope that anyone can help me.

Cheers, Adrian

Product Version: UE 4.15
Tags:
beforebpcompile.png (875.2 kB)
afterbpcompile.png (863.2 kB)
cannotfindvar.png (154.7 kB)
more ▼

asked Mar 29 '17 at 08:22 AM in Bug Reports

avatar image

ZABBA_THE_HUT
16 2 6

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hey ZABBA-

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here https://issues.unrealengine.com/issue/UE-43439 . You can track the report's status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

Cheers

Doug Wilson

more ▼

answered Mar 29 '17 at 01:45 PM

avatar image ZABBA_THE_HUT May 29 '17 at 06:57 AM

Hey Doug,

thanks for your fast reply. I got the same error message again. This time I cannot access the Component (this time a SkeletalMesh) at all. When i click on a SkeletalMeshComponent added via the blueprint editor, then i can change the mesh etc. When the component is added through a member of a C++ subclass (like ChildMesh in MySceneComponent in the example above) it has the same bugs like in the example above.

It seems like the components that are not in the same class as MyActor.h are not initialized correctly. If i add a component through blueprint as a child to a MotionController component (from c++) it does not follow the Controller, although the position is tracked correctly, as i visualized with the help of a DrawDebugSphere() command. Also the Details Panel is again empty.

This time i have two ChildClasses of the same type: LeftHand and RightHand are both of a custom class VRHand. They both contain a MotionController Component with a SkeletalMesh attached to it. If I create a Blueprint as a child of my pawn class then besides the bugs above all seems correct in the hierarchy. If i restart the editor something wierd happens as the Components inside the RightHand switch over to the LeftHand. See the picture for clarification:

alt text

I guess all I'm trying to say is that there seems to be more wrong with the C++ class handling in the blueprints than a disappearing mesh. The whole "custom class as member in another class" seems a little broken.

Thank you very much and best regards, ZABBA

(comments are locked)
10|2000 characters needed characters left
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