Engine crash after using this C++ Function

Hi,

i have created a plugin. Within this plugin there is an easy function.
But when i use this function in BP, the engine crashes.

Here is the function. I have figured out that the for loop is responsible for the crash.

void ARaidfireGravityActor::UpdateGravityActors(const UObject* WorldContextObject, TSet<ARaidfireGravityActor*>& OutGravityActors)
{
	QUICK_SCOPE_CYCLE_COUNTER(ARaidfireGravityActor_UpdateGravityActors);
	OutGravityActors.Reset();
	
	UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
	for(TActorIterator<AActor> It(World); It; ++It)
		{
			
		}
}

I have copied this for loop from the “get all actors of class” function.

Thanks in advance

To be clear the game won’t crash if you remove the loop? First I would check your world pointer as that may actually be the nullptr that is getting called. I would run through this in debug mode with visual studio that should give you more information.

Yeah, the world pointer was the critical thing.

I forgot to declare the right meta data in ufunction