Description

Attempting to spawn a copy of an actor that has components that were added to an instance of that actor in the level causes a crash. Spawning the actor without adding additional components to the instance that you are spawning a copy of works without issue.

Found in 4.10.1 binary.

As a result of the repro steps for this issue being a bit complex, I have also uploaded a test project to Google Drive: [Link Removed]

To repro using the test project, select the "New Blueprint" instance in the level, add a Cone component using the details panel and PIE. The editor will crash.

Steps to Reproduce

1. Open the editor and create a new first person code project
2. Create a c++ class based on Blueprint Function Library
3. In the .h, add this code:

UFUNCTION(BlueprintCallable, Category = "Test")
     static AActor* SpawnActorFromTemplate(AActor* anOwner, AActor* aTemplate, const FTransform aTransform, ESpawnActorCollisionHandlingMethod aCollisionHandling = ESpawnActorCollisionHandlingMethod::AlwaysSpawn);

4. In the .cpp, add this code:

AActor* UBlueprintFunctionLib::SpawnActorFromTemplate(AActor* anOwner, AActor* aTemplate, const FTransform aTransform, ESpawnActorCollisionHandlingMethod aCollisionHandling /*= ESpawnActorCollisionHandlingMethod::AlwaysSpawn*/)
{
	if (anOwner && aTemplate)
	{
		FActorSpawnParameters params;
		params.Template = aTemplate;
		params.SpawnCollisionHandlingOverride = aCollisionHandling;
		params.ObjectFlags = RF_Transient;

		return anOwner->GetWorld()->SpawnActor(aTemplate->GetClass(), &aTransform, params);
	}

	return nullptr;
}

5. Compile the project
6. In the Editor, create a new actor blueprint
7. Add a Cube and a Point Light component to the actor
8. Place an instance of the Actor in the level
9. Open the level blueprint
10. On Event Begin Play, call your Spawn Actor From Template Function.
11. For An Owner, Connect a Self reference. For A Template, Use a reference to the Actor Blueprint that you added to the level in step 8. For A Transform, Get the Player Pawn and Get Actor Transform.
12. In the level, select your instance of your Actor Blueprint, and add a component using the details panel. I added a Cone.
13. PIE

Result: Adding this component to the instance, and then attempting to spawn a copy of that instance causes the editor to crash.

Expected: No crash would occur

Have Comments or More Details?

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

0
Login to Vote

Cannot Reproduce
ComponentUE - Gameplay
Affects Versions4.10
CreatedDec 11, 2015
ResolvedMar 9, 2016
UpdatedJul 14, 2021
View Jira Issue