Game crashes in packaged build

I can play normally in editor without problems, however, when I package my game (development or shipping), my game crashes when I shoot some bullets (it’s random - sometimes I can get away with shooting a few before it crashes). If I just move around and not shoot, I can play for a couple of minutes but it will eventually crash (my player pawn uses sphere collision too).

I’ve attached the important parts of the log below, anyone know what could be causing this?


Could you post the code for the bullets and the player pawn? Are you spawning anything else that uses the sphere collision component? It looks like it’s crashing in the InvalidateOrUpdateSphereBodySetup() function where it checks for the component having only 1 collision primitive, but somehow you have more (or perhaps 0?).

Are you adding sphere components somewhere during runtime?

Hey Wilson,

Both my player and bullet have a sphere collision component as the root and a static mesh as a child of that comp. I’ve enabled auto weld on the static mesh for both.

The bullets are subclasses of a base bullet class. The base bullet class has the setup and the different bullets just inherit the collision and static mesh components.

Bullet.cpp (Base class)

SphereCollision = CreateDefaultSubobject<USphereComponent>(TEXT("SphereCollision"));
SphereCollision->bReturnMaterialOnMove = true; // this is important if we want the FHitResult to return the PhysMaterial
RootComponent = SphereCollision;

BulletMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BulletMesh"));

ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovement"));

// set the collision profile to "Projectile" (this is created in the object channel)

What do you mean by “adding sphere components somewhere during runtime”?

I’m not sure why the editor doesn’t crash or when I right click the uproject and hit “launch game”.

Anyway, I appreciate the help :smiley:

By the way, that game in your sig looks cool :stuck_out_tongue:

I am getting a different stack trace when it crashes - making it even harder to solve.

Here’s another:

I just commented out the bullet spawning code and it stopped crashing. So I guess the problem is with how they are spawned? Anyone know what’s wrong with the following?

    // spawn the bullet
    if (Bullet != nullptr) {
        FVector Location = MuzzleLocation->GetComponentLocation();
        FRotator Rotation = MuzzleLocation->GetComponentRotation();
        FActorSpawnParameters SpawnInfo;
        SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;

        auto bullet = GetWorld()->SpawnActor<ABullet>(Bullet, Location, Rotation, SpawnInfo);
        if (bullet) {
            bullet->BulletInformation.Instigator = InstigatorPC;
            bullet->BulletInformation.DamageCauser = this;
            FiredBullets.Add(bullet); // I started storing them here thinking they were being garbage collected