Description

Using a custom spawn function to spawn a character will crash editor in PIE mode (only standalone window crashes if standalone is used).

Steps to Reproduce
  1. Open UE4 Editor (Top Down Code project)
  2. In PlayerController.h add the following to the public section:
    UFUNCTION(BlueprintCallable, Category = Default)
    		AActor* SpawnActor2(TSubclassOf<AActor> actorClass, AActor* actorTemplate, FVector position);
  3. In PlayerController.cpp add the following:
    AActor* AFTickTaskManagerPlayerController::SpawnActor2(TSubclassOf<AActor> actorClass, AActor* actorTemplate, FVector position)
    {
    	FActorSpawnParameters SpawnInfo;
    	SpawnInfo.bNoCollisionFail = true;
    	SpawnInfo.Owner = this;
    	SpawnInfo.Instigator = nullptr;
    	SpawnInfo.bDeferConstruction = false;
    	SpawnInfo.Template = actorTemplate;
    	auto world = GetWorld();
    	auto actor = world->SpawnActor<AActor>(actorClass, SpawnInfo);
    	actor->SetActorLocation(position);
    	return actor;
    }
  4. Compile and open the project
  5. In Event Graph for MyCharacter add Event Begin Play node
  6. Cast to PlayerController
  7. From return pin, create custom spawn node
  8. Set Actor class to MyCharacter

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.5.1
CreatedDec 30, 2014
ResolvedMar 5, 2015
UpdatedJul 14, 2021
View Jira Issue