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"

blueprint component hierarchy is not the same in editor and in scene

Hello, I'm struggling with components, So I've created an actor class with differents custom component to group up components. From this class, I've created a blueprint on which, I've had meshComponents into those custom components. The problem is that when I put my blueprint in a scene, All the components I've add on the blueprint, magicaly goes under the actor root component.

Here is my Actor class :

 UCLASS()
 class AEditorGizmo : public AActor
 {
     GENERATED_BODY()
 
 public:
     AEditorGizmo();
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     UEditorGizmoToolComponent* TranslationTool;
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     UEditorGizmoToolComponent* RotationTool;
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     UEditorGizmoToolComponent* ScaleTool;
 }
 
 AEditorGizmo::AEditorGizmo()
 {
     USceneComponent* root = CreateDefaultSubobject<UMeshComponent>("Root");
     RootComponent = root;
     TranslationTool = CreateDefaultSubobject<UEditorGizmoToolComponent>("Translation");
     TranslationTool->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
     RotationTool = CreateDefaultSubobject<UEditorGizmoToolComponent>("Rotation");
     RotationTool->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
     ScaleTool = CreateDefaultSubobject<UEditorGizmoToolComponent>("Scale");
     ScaleTool->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
 
 }

And here is the custom component code

 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class UEditorGizmoToolComponent : public USceneComponent
 {
     GENERATED_BODY()
 
 public:    
     // Sets default values for this component's properties
     UEditorGizmoToolComponent();
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         USceneComponent* XAxis;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         USceneComponent* YAxis;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
         USceneComponent* ZAxis;
     
 };
 
 UEditorGizmoToolComponent::UEditorGizmoToolComponent()
 {
     PrimaryComponentTick.bCanEverTick = true;
 
     FName axisName = FName(*("XAxis" + GetName()));
     XAxis = CreateDefaultSubobject<USceneComponent>(axisName);
     XAxis->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
     axisName = FName(*("YAxis" + GetName()));
     YAxis = CreateDefaultSubobject<USceneComponent>(axisName);
     YAxis->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
     axisName = FName(*("ZAxis" + GetName()));
     ZAxis = CreateDefaultSubobject<USceneComponent>(axisName);
     ZAxis->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
 
 }

In the blueprint editor

alt text

In the scene hierarchy

alt text

Product Version: UE 4.18
Tags:
more ▼

asked Feb 08 '18 at 04:40 PM in C++ Programming

avatar image

benjaml
26 5 5 8

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

1 answer: sort voted first

I found a solution !

To correct this behavior, I've created X, Y and Z Axis scene component directly in the actor constructor like this :

 AEditorGizmo::AEditorGizmo()
 {
     USceneComponent* root = CreateDefaultSubobject<USceneComponent>("Root");
     RootComponent = root;
     TranslationTool = CreateDefaultSubobject<UEditorGizmoToolComponent>("Translation");
     TranslationTool->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
     RotationTool = CreateDefaultSubobject<UEditorGizmoToolComponent>("Rotation");
     RotationTool->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
     ScaleTool = CreateDefaultSubobject<UEditorGizmoToolComponent>("Scale");
     ScaleTool->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
     TranslationTool->XAxis = CreateDefaultSubobject<USceneComponent>("XAxisTranslation");
     TranslationTool->XAxis->AttachToComponent(TranslationTool, FAttachmentTransformRules::KeepRelativeTransform);
     TranslationTool->YAxis = CreateDefaultSubobject<USceneComponent>("YAxisTranslation");
     TranslationTool->YAxis->AttachToComponent(TranslationTool, FAttachmentTransformRules::KeepRelativeTransform);
     TranslationTool->ZAxis = CreateDefaultSubobject<USceneComponent>("ZAxisTranslation");
     TranslationTool->ZAxis->AttachToComponent(TranslationTool, FAttachmentTransformRules::KeepRelativeTransform);
     RotationTool->XAxis = CreateDefaultSubobject<USceneComponent>("XAxisRotation");
     RotationTool->XAxis->AttachToComponent(RotationTool, FAttachmentTransformRules::KeepRelativeTransform);
     RotationTool->YAxis = CreateDefaultSubobject<USceneComponent>("YAxisRotation");
     RotationTool->YAxis->AttachToComponent(RotationTool, FAttachmentTransformRules::KeepRelativeTransform);
     RotationTool->ZAxis = CreateDefaultSubobject<USceneComponent>("ZAxisRotation");
     RotationTool->ZAxis->AttachToComponent(RotationTool, FAttachmentTransformRules::KeepRelativeTransform);
     ScaleTool->XAxis = CreateDefaultSubobject<USceneComponent>("XAxisScale");
     ScaleTool->XAxis->AttachToComponent(ScaleTool, FAttachmentTransformRules::KeepRelativeTransform);
     ScaleTool->YAxis = CreateDefaultSubobject<USceneComponent>("YAxisScale");
     ScaleTool->YAxis->AttachToComponent(ScaleTool, FAttachmentTransformRules::KeepRelativeTransform);
     ScaleTool->ZAxis = CreateDefaultSubobject<USceneComponent>("ZAxisScale");
     ScaleTool->ZAxis->AttachToComponent(ScaleTool, FAttachmentTransformRules::KeepRelativeTransform);
 
 }
more ▼

answered Feb 09 '18 at 08:47 AM

avatar image

benjaml
26 5 5 8

(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