BlueprintNativeEvent Garbage collection interference??

Adam
Tue, 29 Mar 2022 17:05:36 +0000
C++

I’m working on a plugin and have implemented an overrideable function (BlueprintNativeEvent) that’s working correctly 90% of the time…

The exception is once every minute it seems as if the function call is skipped entirely.

I have tried a lot of different declarations, specifier combinations and variants on the definition as well but am still getting the same weird behavior in unreal UE5 preview 2 as in engine 4.26 (PIE and stand alone).

.h

UFUNCTION(BlueprintCallable, BlueprintNativeEvent, CallInEditor)
	struct FHitResult CustomSpawnPointFunction(FVector2D Position);

virtual struct FHitResult CustomSpawnPointFunction_Implementation(FVector2D Position);

.cpp

struct FHitResult AProceduralInstanceSpawner::CustomSpawnPointFunction_Implementation(FVector2D Position)
{
	struct FHitResult Hit;

	AsyncTask(ENamedThreads::GameThread, [this]()
	{
		Print("Custom function not overridden.", 3, FColor::Orange, -1);
	}
	);

	return Hit;
}

In code:

//Use custom function
	if (TraceMethod == UseCustomFunction)
	{
		OutHit.bBlockingHit = false;
		OutHit = CustomSpawnPointFunction(TracePosition);

		if (!OutHit.bBlockingHit)
		{
			Print("Custom function returning false.", 3, FColor::Red, -1);

			return false;
		}

		return true;
	}

Once every minute the “Custom function returning false” message is printed even though blocking hit is set to true in the override.

Never had a function behaving like this before. Anybody got a clue on what’s going on??

1 post - 1 participant