Packaged project wont start (no logs generated)

It’s very easy to reproduce:

  1. Create new project (I used the c++ vehicle template)
  2. Open [ProjectName]Pawn.cpp and add the following line to create a static variable (don’t add it inside a function)
    TArray< TEnumAsByte< EObjectTypeQuery > > ObjectTypes{ UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Vehicle) };
  3. Compile Visual studio project
  4. Open unreal project
  5. Package build
  6. Try to open the build

It took me 3 days to track the issue down to that one line, it happens in both UE 5.3.2 and UE 5.4.2.
I hope this saves some time for other developers.

Does anyone have any idea why would that line cause the packaged project to not open ? It would not even generate Saved\Logs.

TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes{ UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Vehicle) };

should be

TArray<TEnumAsByte<EObjectTypeQuery>> ASpeedyPawn ::ObjectTypes{};

.h

static TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;

UFUNCTION(BlueprintCallable)
static void InitObjectTypes();
static bool isInit;

Then you can init it with a static function

UFUNCTION(BlueprintCallable)
static void InitObjectTypes();

void ASpeedyPawn ::InitObjectTypes()
{
	if (ASpeedyPawn ::isInit == false) {
		ASpeedyPawn ::ObjectTypes = TArray<TEnumAsByte<EObjectTypeQuery>>{ UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Vehicle) };
		ASpeedyPawn ::isInit = true;
	}
}

Seeing as it’s in the class ASpeedyPawn and is a static variable. If you do not use the class name then you can’t access it’s static variables.

The part that derails the project is

UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Vehicle)

if you pass in the direct channel eg.
EObjectTypeQuery::ObjectTypeQuery16

so in cpp init as

TArray<TEnumAsByte<EObjectTypeQuery>> Athirdp54Character::ObjectTypes{ EObjectTypeQuery::ObjectTypeQuery16 };

Then you can pack without the extra set of the init function.

I can only guess that UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Vehicle) either is either stripped out in the packed version or maybe the static array is filled at a time where the UEngineTypes::ConvertToObjectType is calling some part of the engine that isn’t loaded yet.

1 Like