# ChildActorComponent: ChildActorTemplate causes crash when native child actor class changed

**URL:** <https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645>\
**Category:** C++\
**Tags:** child-actor-componen, unreal-engine, crash, bug-report, editor, CPP, question\
**Created:** [February 1, 2017, 5:54pm UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645 "2017-02-01T17:54:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_bddde7ba1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bddde7ba1](https://forums.unrealengine.com/u/anonymous_user_bddde7ba1)\
**Post date:** [February 1, 2017, 5:54pm UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645/1 "2017-02-01T17:54:49Z")

</div>

The crash occurs when native child class used in the ChildActorComponent has been changed and new native components have been added. To reproduce that I have created two C++ actors and one of those contains a ChildActorComponent:

ParentActor.h

```
UCLASS()
class TEST_API AParentActor : public AActor
{
GENERATED_BODY()
public:	

AParentActor();

UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Instanced, Category = Test)
class UChildActorComponent* ChildActorComponent;
};

```

ParentActor.cpp

```
AParentActor::AParentActor()
{
ChildActorComponent = CreateDefaultSubobject<UChildActorComponent>(TEXT("ChildActorComponent"));
ChildActorComponent->SetupAttachment(GetRootComponent());

```

}

ChildActor.h

```
UCLASS()
class TEST_API AChildActor : public AActor
{
 GENERATED_BODY()
 public:	

    AChildActor();	
};

```

ChildActor.cpp

```
AChildActor::AChildActor()
{

}

```

Then I have created two blueprints for those actors and assigned ChildActor blueprint class as a class of Parent’s ChildActorComponent. ChildActorComponent creates and set its ChildActorTemplate.

After closing the editor I have added a new component to the child class:

ChildActor.h

```
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Collision)
UCapsuleComponent* CollisionComponent;

```

ChildActor.cpp

```
AChildActor::AChildActor()
{
   CollisionComponent= CreateDefaultSubobject<UCapsuleComponent>(TEXT("CollisionComponent"));
   if (CollisionComponent)
   {
	   SetRootComponent(CollisionComponent);
   }
}

```

After that change the editor is crashing all the time on loading of the parent blueprint (when I try to open that blueprint for editing) failing to find an Outer for that new component.

```
checkf(SubobjectOuter, TEXT("No corresponding destination object found for '%s' while attempting to instance component '%s'"), *SourceSubobject->GetOuter()->GetFullName(), *SourceSubobject->GetFullName());

```

Here is a call stack:

> UE4Editor-CoreUObject.dll!FObjectInstancingGraph::GetInstancedSubobject(UObject \* SourceSubobject, UObject \* CurrentValue, UObject \* CurrentObject, bool bDoNotCreateNewInstance, bool bAllowSelfReference) Line 181 C++  
> UE4Editor-CoreUObject.dll!FObjectInstancingGraph::InstancePropertyValue(UObject \* ComponentTemplate, UObject \* CurrentValue, UObject \* Owner, bool bIsTransient, bool bCausesInstancing, bool bAllowSelfReference) Line 280 C++  
> UE4Editor-CoreUObject.dll!UObjectPropertyBase::InstanceSubobjects(void \* Data, const void \* DefaultData, UObject \* Owner, FObjectInstancingGraph \* InstanceGraph) Line 34 C++  
> UE4Editor-CoreUObject.dll!UStruct::InstanceSubobjectTemplates(void \* Data, const void \* DefaultData, UStruct \* DefaultStruct, UObject \* Owner, FObjectInstancingGraph \* InstanceGraph) Line 1456 C++  
> UE4Editor-CoreUObject.dll!FObjectInitializer::InstanceSubobjects(UClass \* Class, bool bNeedInstancing, bool bNeedSubobjectInstancing) Line 2942 C++  
> UE4Editor-CoreUObject.dll!FObjectInitializer::PostConstructInit() Line 2826 C++  
> UE4Editor-CoreUObject.dll!FObjectInitializer::~FObjectInitializer() Line 2684 C++  
> UE4Editor-CoreUObject.dll!StaticConstructObject\_Internal(UClass \* InClass, UObject \* InOuter, FName InName, EObjectFlags InFlags, EInternalObjectFlags InternalSetFlags, UObject \* InTemplate, bool bCopyTransientsFromClassDefaults, FObjectInstancingGraph \* InInstanceGraph, bool bAssumeTemplateIsArchetype) Line 3212 C++  
> UE4Editor-Engine.dll!NewObject(UObject \* Outer, UClass \* Class, FName Name, EObjectFlags Flags, UObject \* Template, bool bCopyTransientsFromClassDefaults, FObjectInstancingGraph \* InInstanceGraph) Line 1227 C++  
> UE4Editor-Engine.dll!UWorld::SpawnActor(UClass \* Class, const FTransform \* UserTransformPtr, const FActorSpawnParameters & SpawnParameters) Line 405 C++  
> UE4Editor-Engine.dll!UWorld::SpawnActor(UClass \* Class, const FVector \* Location, const FRotator \* Rotation, const FActorSpawnParameters & SpawnParameters) Line 271 C++  
> UE4Editor-Engine.dll!UChildActorComponent::CreateChildActor() Line 482 C++  
> UE4Editor-Engine.dll!UActorComponent::ExecuteRegisterEvents() Line 1179 C++  
> UE4Editor-Engine.dll!UActorComponent::RegisterComponentWithWorld(UWorld \* InWorld) Line 912 C++  
> UE4Editor-Engine.dll!AActor::IncrementalRegisterComponents(int NumComponentsToRegister) Line 4004 C++  
> UE4Editor-Engine.dll!AActor::RegisterAllComponents() Line 3940 C++  
> UE4Editor-Engine.dll!AActor::PostSpawnInitialize(const FTransform & UserSpawnTransform, AActor \* InOwner, APawn \* InInstigator, bool bRemoteOwned, bool bNoFail, bool bDeferConstruction) Line 2728 C++  
> UE4Editor-Engine.dll!UWorld::SpawnActor(UClass \* Class, const FTransform \* UserTransformPtr, const FActorSpawnParameters & SpawnParameters) Line 438 C++  
> UE4Editor-Engine.dll!UWorld::SpawnActor(UClass \* Class, const FVector \* Location, const FRotator \* Rotation, const FActorSpawnParameters & SpawnParameters) Line 271 C++  
> UE4Editor-Kismet.dll!FBlueprintEditor::UpdatePreviewActor(UBlueprint \* InBlueprint, bool bInForceFullUpdate) Line 8062 C++  
> UE4Editor-Kismet.dll!FBlueprintEditor::Tick(float DeltaTime) Line 7028 C++  
> UE4Editor-UnrealEd.dll!FTickableEditorObject::TickObjects(float DeltaSeconds) Line 17 C++  
> UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1195 C++  
> UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 371 C++  
> UE4Editor.exe!FEngineLoop::Tick() Line 2880 C++  
> UE4Editor.exe!GuardedMain(const wchar\_t \* CmdLine, HINSTANCE\_\_ \* hInInstance, HINSTANCE\_\_ \* hPrevInstance, int nCmdShow) Line 152 C++  
> UE4Editor.exe!WinMain(HINSTANCE\_\_ \* hInInstance, HINSTANCE\_\_ \* hPrevInstance, char \* \_\_formal, int nCmdShow) Line 191 C++

If parent blueprint has been saved in the level then the level will also crash. It will not happen if ChildActorComponent of the parent uses a C++ class (ChildActor) instead of a blueprint one (based on ChildActor).

There are ways to load that object again:

- By reverting a change that added a new component, opening parent blueprint and set a class for ChildActorComponent to None, reapplying code change and selecting blueprint class again
- Or by turning off ChildActorTemplate functionality

Please let me know if those steps work for you in order to reproduce the issue.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bddde7ba1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bddde7ba1](https://forums.unrealengine.com/u/anonymous_user_bddde7ba1)\
**Post date:** [February 2, 2017, 10:42am UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645/2 "2017-02-02T10:42:26Z")

</div>

There is another one related to the previous report. Here are steps to reproduce:

- Follow all the steps from the original post but as a last step assign ChildActorClass in the parent’s ChildActorComponent
- Restart the editor and make sure that the Parent actor can be spawned or at least opened for editing
- Open a Child blueprint and add a reference to a Parent blueprint class, e.g. just add a cast to Parent blueprint class

![124608-bpchild.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/c/0/9c0b9dcb55ec7046035de516243e1ecb4fd9f44c.jpeg)

- Restart the editor and try to load Parent blueprint

- The editor will crash here:

A part of the callstack:

> UE4Editor-Engine.dll!UActorComponent::OnRegister() Line 658 C++  
> UE4Editor-Engine.dll!USceneComponent::OnRegister() Line 570 C++  
> UE4Editor-Engine.dll!UPrimitiveComponent::OnRegister() Line 398 C++  
> UE4Editor-Engine.dll!UActorComponent::ExecuteRegisterEvents() Line 1179 C++  
> UE4Editor-Engine.dll!UActorComponent::RegisterComponentWithWorld(UWorld \* InWorld) Line 912 C++  
> UE4Editor-Engine.dll!AActor::IncrementalRegisterComponents(int NumComponentsToRegister) Line 4004 C++  
> UE4Editor-Engine.dll!AActor::RegisterAllComponents() Line 3940 C++

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [February 7, 2017, 9:49pm UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645/3 "2017-02-07T21:49:05Z")

</div>

Hey Sergey.Nt-

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here [Unreal Engine Issues and Bug Tracker (UE-41708)](https://issues.unrealengine.com/issue/UE-41708) . 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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bddde7ba1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bddde7ba1](https://forums.unrealengine.com/u/anonymous_user_bddde7ba1)\
**Post date:** [February 8, 2017, 10:11am UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645/4 "2017-02-08T10:11:27Z")

</div>

Thank you .

---

<div class="post-metadata">

**Author:** ![astonish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@astonish](https://forums.unrealengine.com/u/astonish)\
**Post date:** [February 14, 2017, 5:17pm UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645/5 "2017-02-14T17:17:24Z")

</div>

Upvoting this issue. I had an “Instance component attaching to template object” error with one of our C++ base classes whose BP child classes are often used as a child actor components of pawns. Now all our pawn BPs using those child BPs crash on open.

---

<div class="post-metadata">

**Author:** ![sclark39](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sclark39](https://forums.unrealengine.com/u/sclark39)\
**Post date:** [April 29, 2017, 7:49pm UTC](https://forums.unrealengine.com/t/childactorcomponent-childactortemplate-causes-crash-when-native-child-actor-class-changed/383645/6 "2017-04-29T19:49:22Z")

</div>

I was able to work around this issue by setting the ChildActorComponent’s class to the code derived blueprint from the parent’s BeginPlay blueprint event.

I believe this is a better workaround than the OP’s suggestion to change the ChildActorComponent to None, update, and then change back,
