bool UMovementComponent::ShouldSkipUpdate(float DeltaTime) const { if (UpdatedComponent == nullptr) { return true; } if (UpdatedComponent->Mobility != EComponentMobility::Movable) { #if WITH_EDITOR if (!bEditorWarnedStaticMobilityMove) { if (UWorld * World = GetWorld()) { if (World->HasBegunPlay() && IsRegistered()) { const_cast<UMovementComponent*>(this)->bEditorWarnedStaticMobilityMove = true; FMessageLog("PIE").Warning(FText::Format(LOCTEXT("InvalidMove", "Mobility of {0} : {1} has to be 'Movable' if you'd like to move it with {2}. "), FText::FromString(GetNameSafe(UpdatedComponent->GetOwner())), FText::FromString(UpdatedComponent->GetName()), FText::FromString(GetClass()->GetName()))); } } } #endif return true; } if (bUpdateOnlyIfRendered) { if (GetNetMode() == NM_DedicatedServer) { // Dedicated servers never render return true; } const float RenderTimeThreshold = 0.41f; UWorld* TheWorld = GetWorld(); if (UpdatedPrimitive && TheWorld->TimeSince(UpdatedPrimitive->LastRenderTime) <= RenderTimeThreshold) { return false; // Rendered, don't skip it. } // Most components used with movement components don't actually render, so check attached children render times. TArray<USceneComponent*> Children; UpdatedComponent->GetChildrenComponents(true, Children); for (auto Child : Children) { const UPrimitiveComponent* PrimitiveChild = Cast<UPrimitiveComponent>(Child); if (PrimitiveChild) { if (PrimitiveChild->IsRegistered() && TheWorld->TimeSince(PrimitiveChild->LastRenderTime) <= RenderTimeThreshold) { return false; // Rendered, don't skip it. } } } // No children were recently rendered, safely skip the update. return true; } return false; }