I’m currently creating a “chain” projectile that will spawn another projectile or explosion actor on impact before immediately destroying itself. Things are mostly working but a few things are off and these mass warnings are an obvious red flag that I can’t seem to get rid of because the engine doesn’t tell me where it occurred!
My projectiles are essentially just actors with a StaticMeshComponent and a ProjectileMovementComponent.
Every time I spawn new projectiles I get this warning:
LogUObjectBase: Warning: NULL object
Just to try to over explain WHEN the warning is showing:
Projectile1 Collision → Spawn Projectile2 → Projectile1 Destroys self → Warning
I’ve tried storing the spawned actor (“Projectile2”) as a UPROPERTY() in “Projectile1” because it could be an issue with garbage collection. No luck there.
I’ve also tried NOT destroying the “Projectile1” after spawning the new one (“Projectile2”) - just to see if I could get rid of the warning. This resulted in the warning showing up much less often (like ~50% of the spawns)
Here is my spawn projectile Code:
AGameProjectile* AGameMeshProjectileChain::SpawnProjectileChain(const FVector& Location, const FRotator& Rotation)
{
AGameProjectile* SpawnedProjectile = nullptr;
FActorSpawnParameters ProjectileSpawnParams;
ProjectileSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
// spawn projectile
UWorld* World = GetWorld();
if (World)
SpawnedProjectile = World->SpawnActor<AGameProjectile>(ProjectileChainClass, Location, Rotation, ProjectileSpawnParams);
if (SpawnedProjectile != nullptr)
{
// set projectile owner
if (GetOwner() != nullptr)
SpawnedProjectile->SetOwner(GetOwner());
else
SpawnedProjectile->SetOwner(this);
}
return SpawnedProjectile;
}
I’m not entirely sure what bit of code is relevant here because the warning doesn’t point me in a direction. This function produces a completely valid actor from what I can gather. I’ve narrowed it down as much as I have now using UE_LOGs all over the place. I would be more than happy to give you more to look at if this is unhelpful.
I’m fairly certain that it has something to do with the actor destroying itself immediately after spawning another - but keeping it alive only seems to lessen the warning spam and obviously isn’t practical. I’m praying you brilliant people will point out something I’m doing incorrectly!
I’m using the newest engine v 4.24.1