Skip to content
Snippets Groups Projects
Commit 28a90bb7 authored by Konstantin Kühlem's avatar Konstantin Kühlem
Browse files

fix: Set anim tick behavior for all VH related meshes automatically to avoid de-sync on NDisplay

parent c4b72bd7
Branches
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#include "VirtualHumanAIController.h"
#include "Engine/Engine.h"
#include "CharacterPluginLogging.h"
#include "HairStrandsInterface.h"
AVirtualHuman::AVirtualHuman()
{
......@@ -36,6 +37,19 @@ void AVirtualHuman::BeginPlay()
// constantly seed the random stream so we don't have cluster syncing problems
// but seed it with the name of the VH, so random behavior is different for every VH
IdleRandomStream = FRandomStream(TextKeyUtil::HashString(GetName()));
// Ensure all mesh components tick no matter if they are rendered
// THis fixes de-synced animations on different cluster nodes
if (FModuleManager::Get().IsModuleLoaded("DisplayCluster")
&& IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
TArray<USkeletalMeshComponent*> Meshes;
GetComponents(Meshes, true);
for (USkeletalMeshComponent* M : Meshes)
{
M->VisibilityBasedAnimTickOption = EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones;
}
}
}
// Called every frame
......@@ -332,7 +346,9 @@ void AVirtualHuman::PlayRandomIdleAnimation()
IdleAnim, "CustomIdleSlot", BlendTime, BlendTime);
// start timer for next random pick (make it a bit shorter to allow for blending, but only by a defined minimal amount for the animations)
GetWorld()->GetTimerManager().SetTimer(NextIdleTimerHandle, this, &AVirtualHuman::PlayRandomIdleAnimation,
DynamicMontage->GetPlayLength() - fmin(2.0 * BlendTime, (DynamicMontage->GetPlayLength()) * MinBlendTime), false);
DynamicMontage->GetPlayLength() - fmin(
2.0 * BlendTime, (DynamicMontage->GetPlayLength()) * MinBlendTime),
false);
}
else
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment