# Child componentes are promoted, not deleted, when I delete my custom USceneComponent from a pawn in the editor

**URL:** <https://forums.unrealengine.com/t/child-componentes-are-promoted-not-deleted-when-i-delete-my-custom-uscenecomponent-from-a-pawn-in-the-editor/476016>\
**Category:** C++\
**Tags:** child-actor-componen, unreal-engine, question\
**Created:** [December 16, 2020, 6:17pm UTC](https://forums.unrealengine.com/t/child-componentes-are-promoted-not-deleted-when-i-delete-my-custom-uscenecomponent-from-a-pawn-in-the-editor/476016 "2020-12-16T18:17:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0a12e393](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0a12e393](https://forums.unrealengine.com/u/anonymous_user_0a12e393)\
**Post date:** [December 16, 2020, 6:17pm UTC](https://forums.unrealengine.com/t/child-componentes-are-promoted-not-deleted-when-i-delete-my-custom-uscenecomponent-from-a-pawn-in-the-editor/476016/1 "2020-12-16T18:17:44Z")

</div>

I have a USceneComponent I’m attaching to Actors/Pawns in the editor (currently just using the empty pawn). The USceneComponent creates a UStaticMeshComponent in the contrusctor and attaches it to the USceneComponent.

```
UDisplayBase::UDisplayBase()
{
	PrimaryComponentTick.bCanEverTick = true;

	// Create the static mesh subcomponent
	DisplaySurface = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("DisplaySurface"));
	DisplaySurface->SetupAttachment(this);	
}

```

 ![324999-screenshot-2020-12-16-180616.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/e/a0eb0f75b70da5da26d8a07dd8877863fac74b78.png)

If I then right click and delete the DisplayBase object within the editor then it Promotes the UStaticMeshComponent up to be a direct child of the DefaultSceneRoot and I am not able to delete it.

I have identical behaviour with another of my custom USceneComponent classes so I’m clearly missing a step here. Is anyone able to provide an example of how to properly handle the delete process? I can see DestroyComponent but not certain this is the answer I’m looking for. Feel more like I haven’t quite got my structure setup correctly.

 ![325010-screenshot-2020-12-16-181300.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/1/651de041df62d6eee0b2d1b0be6ec995304106fc.png)

Child component promoted and now unable to delete. It is deleted if I delete the Pawn.

 ![325011-screenshot-2020-12-16-181348.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/c/b/6cb89b8806b175cdf30f04e668b765ff2e0b115b.png)

 ![325012-screenshot-2020-12-16-181544.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/3/8d32dbdc202ce73f2db0c07af9a85d3fb0ca72f0.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0a12e393](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0a12e393](https://forums.unrealengine.com/u/anonymous_user_0a12e393)\
**Post date:** [December 22, 2020, 9:40am UTC](https://forums.unrealengine.com/t/child-componentes-are-promoted-not-deleted-when-i-delete-my-custom-uscenecomponent-from-a-pawn-in-the-editor/476016/2 "2020-12-22T09:40:57Z")

</div>

Had put this on the back burner and then it started to bother me again.

I (think) I have resolved by overriding the “DestroyComponent” function - at least the child objects are no longer appearing in the editor anymore.

\*.h

```
protected:
    virtual void DestroyComponent(bool bPromoteChildren) override;

```

\*.cpp

```
void UMyComoponent::DestroyComponent(bool bPromoteChildren) 
{
	if (MySubComponent)
	{
		MySubComponent->DestroyComponent(bPromoteChildren);
	}

	Super::DestroyComponent(bPromoteChildren);
}

```
