[4.9]SpawnActor called from Lib blueprint now crashes

This code has always worked, now in 4.9 it crashes. Calling spawn actor from blueprint node inside a blueprint lib function. I don’t see a world context pin or anything. Any suggestions?

UWorld* UEngine::GetWorldFromContextObject(const UObject* Object, const bool bChecked) const
{
if (!bChecked && Object == NULL)
{
return NULL;
}

// Object is NULL, crashes here…

check(Object);

bool bSupported = true;
UWorld* World = (bChecked ? Object->GetWorldChecked(bSupported) : Object->GetWorld());
return (bSupported ? World : GWorld);

}

AActor* UGameplayStatics::BeginDeferredActorSpawnFromClass(UObject* WorldContextObject, TSubclassOf ActorClass, const FTransform& SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingMethod, AActor* Owner)
{
AActor* NewActor = NULL;

UClass* Class = *ActorClass;
if (Class != NULL)
{
	// If the WorldContextObject is a Pawn we will use that as the instigator.
	// Otherwise if the WorldContextObject is an Actor we will share its instigator.
	// If the value is set via the exposed parameter on SpawnNode it will be overwritten anyways, so this is safe to specify here
	APawn* AutoInstigator = Cast<APawn>(WorldContextObject);
	if (AutoInstigator == nullptr)
	{
		AActor* ContextActor = Cast<AActor>(WorldContextObject);
		if (ContextActor)
		{
			AutoInstigator = ContextActor->Instigator;
		}
	}

	UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);

hey -

Could you post the log files from the crash for additional information? In trying to reproduce this I created a blueprint function library function that calls SpawnActor and then set my character to call this function. Testing the call in game did not cause any crash for me. If you’re able to reproduce the crash in a fresh project with no additional content please include the steps you took that led to the crash.

Cheers

I found out how to reproduce it. I have two functions in my blueprint lib. The first one calls the second one. When calling the second lib blueprint node a world context pin was set to an actor, if I keep that null then it’s OK, but if it’s set to something it crashes. The second function calls spawn actor.

Could you add screenshots of how your blueprint function library is setup? What are the two functions being called doing? Where is the first function being called from? If you call the second function directly (without calling the first) does the crash still occur? Additionally, please include the log files in the projects Saved/Logs folder to provide more information on what exactly is failing when the crash occurs.

Hi ,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.