Description

Attempting to add multiple instances of a Scene Component that was created in code and contains a component such as a Box Collider causes the Box Colliders of each Scene Component to be parented to the most recently added one, instead of the one that it should be attached to.

Found in 4.10.1. Reproduced in 4.11 Preview 1 and Main CL 2811183

Steps to Reproduce

1. Open the editor
2. Create a new C++ class based on Scene Component
3. Add this code to the .h

 UPROPERTY(EditAnywhere, BlueprintReadWrite)
         UBoxComponent* Box;

4. Add this code to the .cpp

Box = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollider")); 
Box->AttachTo(this);

5. Compile
6. Back in the Editor, create a new Actor Blueprint
7. Add two instances of the C++ class you created as components
8. Drag your Actor into the level (Notice that the box colliders are correctly parented when you first drag it in if you look in the component tree in the Details Panel of the viewport)
9. Click off of the Actor, and then reselect it.

Result: The Box components are now parented to the last Scene Component, instead of being parented to the correct owners.

Expected: The box components would attach to each individual scene component, not the most recent one.

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

0
Login to Vote

Fixed
ComponentUE - Gameplay - Components
Affects Versions4.104.114.12
Target Fix4.13
Fix Commit3004871
Main Commit3025946
CreatedJan 5, 2016
ResolvedJun 7, 2016
UpdatedApr 27, 2018