Some Soft Pointer Asset Invalid

Hello there, I have a problem where my Soft Pointer is invalid. However, this isn’t happening to all of the assets. There are some assets that invalid if I check the validity of the Soft Pointer:

if (!WeaponTrailTemplate.IsValid())
{
	return;
}

This is happening on Packaged game and Standalone game.
All of the invalid assets are already cooked properly (I already check on the .pak file and they are there). If I use Hard Reference, that invalid asset is loaded and worked.

I’m confused about what is the trouble, since only some of them are invalid, I think the problem isn’t with my code.

This is WeaponTrailTemplate by the way:

UPROPERTY(Transient, EditAnywhere, Category = "Components")
TSoftObjectPtr<UParticleSystem> WeaponTrailTemplate;

I initialize it from Blueprint so the path should be handled automatically (I log the path and it’s correct) but still invalid.

Do you have any idea about this? Thanks!

Here is the code:

void AWeapon::LoadWeaponTrail()
{
	if (!WeaponTrailTemplate.IsValid())
	{
		return;
	}

	WeaponTrailHandle = UAssetManager::GetStreamableManager().RequestAsyncLoad(WeaponTrailTemplate.ToSoftObjectPath(),
		[this]() 
		{
			if (WeaponTrail)
			{
				if (IsValid(WeaponTrailTemplate.Get()))
				{
					WeaponTrail->SetTemplate(WeaponTrailTemplate.Get());
					WeaponTrail->SetFloatParameter(TrailLifetimeParam, TrailLifetime);
				}
			}

			if (WeaponTrailHandle->IsActive())
			{
				WeaponTrailHandle->CancelHandle();
			}
		});
}

This is an issue of the soft pointer API being a bit confusing. IsValid() checks whether the asset referenced by the soft pointer is loaded but for some reason Epic named it this way instead of something like IsLoaded(). If you want to check whether the soft pointer correctly references an asset, use IsNull().

1 Like

I see, thank you very much! with this information I can track the problem better!