ワールドパーティションで遠くへワープをするとき、地形の読み込み待ちが発生し、FDefaultGameMoviePlayerでローディング画面が表示されると思います。
このローディング画面が2回も呼ばれてしまうので、ワープ開始から終了まで1回だけ表示されるようにしたいです。
ワープするときの処理が良くないのか、ローディング画面を表示するタイミングや処理が良くないのか、判断が付かない状況でした。
正しい実装方法があれば教えていただくことは可能でしょうか。
ワープする時の処理は以下のように行っています。
```
ACharacter* const Character = 操作しているキャラクターを取得;
TObjectPtr<UWorldPartitionStreamingSourceComponent> StreamingSourceComponent; // 外部から設定される
FVector WarpLocation; // ワープ先の座標
GetMoviePlayer()->PlayMovie();
Character->SetActorTransform(WarpLocation, false, nullptr, ETeleportType::TeleportPhysics);
AActor* StreamingSourceActor = StreamingSourceComponent ? StreamingSourceComponent->GetOwner() : nullptr;
if(IsValid(StreamingSourceActor) && IsValid(StreamingSourceComponent))
{
StreamingSourceActor\-\>SetActorLocation(CharacterCenterLocation);
StreamingSourceComponent\-\>EnableStreamingSource();
}
TArray<FWorldPartitionStreamingQuerySource> WorldPartitionStreamingQuerySources = GetWorldPartitionStreamingQuerySource(WarpLocation);
auto TickTimer = [this, WorldPartitionStreamingQuerySources, Character]()
{
if (移動先で必要なアセットなどの読み込み完了か)
{
// 弊社で必要なアセットなどの読み込み待ちをしている
return;
}
GetWorld()\-\>BlockTillLevelStreamingCompleted();
const TObjectPtr\<UWorldPartitionSubsystem\> WorldPartitionSubsystem \= GetWorld()\-\>GetSubsystem\<UWorldPartitionSubsystem\>();
if (WorldPartitionSubsystem\-\>IsStreamingCompleted(EWorldPartitionRuntimeCellState::Activated,WorldPartitionStreamingQuerySources, false))
{
GetMoviePlayer()\-\>StopMovie();
// 読み込み完了後の処理
}
};
GetWorld()->GetTimerManager().SetTimer(TimerHandle, FTimerDelegate::CreateWeakLambda(this, TickTimer), 0.2f, true);
```