Skip to content
Snippets Groups Projects
Commit ca7be93a authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

use a constantly seeded random stream for idle movements, for cluster-robustness.

parent 640e9e7a
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,10 @@ void AVirtualHuman::BeginPlay()
SetUpBodyType();
bFirstTick = true;
// 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(*GetOwner()->GetName()));
}
// Called every frame
......@@ -292,7 +296,7 @@ void AVirtualHuman::PlayRandomIdleAnimation()
}
// play arandom idle animation
int Random = FMath::RandRange(0, CustomIdleAnimations.Num() - 1);
int Random = IdleRandomStream.RandRange(0, CustomIdleAnimations.Num() - 1);
UAnimSequence* IdleAnim = CustomIdleAnimations[Random];
if (IdleAnim)
{
......
......@@ -135,6 +135,7 @@ private:
void PlayRandomIdleAnimation();
UPROPERTY()
FTimerHandle NextIdleTimerHandle;
FRandomStream IdleRandomStream;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment