Hello all,
I have a function on an actor component that creates a new actor. This has been working fine. After making changes to unrelated parts of the actor component, the function began to crash. It appears that, inside of the function, the UWorld being returned from GetWorld() is not valid.
I tried testing in a clean function :
void USPWeaponManager::WorldTesting()
{
UWorld* World = GetWorld();
if(IsValid(World))
{
FString PrintString = World->GetName();
UE_LOG(LogTemp, Warning, TEXT("%s"), *PrintString)
} else
{
UE_LOG(LogTemp, Warning, TEXT("Invalid World"))
}
}
When I call this, I get “Invalid World”. I also tried with GetOwner->GetWorld() to the same result.
Oddly though, I attempted to put this code in the BeginPlay function of my component, and I gat the correct world returned, and it printed “LobbyMap” (the name of the map I’m in).
When I call GetWorld from the actor that this is attached to, I get the world back just fine, so I’m extra confused as to why GetOwner()->GetWorld() is also failing.
I’m not even sure where to begin to look. Any help would be greatly appreciated.
Thanks!