diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphInstance.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphInstance.cpp index 7f9e8ba6fc..61a366f298 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphInstance.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphInstance.cpp @@ -71,6 +71,9 @@ namespace EMotionFX // create the parameter value objects CreateParameterValues(); + // Assign a unique seed for the lcg random number. Here we use the actorInstanceId because it guaranteed to be unique and available on actor instances. + m_lcgRandom.SetSeed(actorInstance->GetID()); + m_animGraph->Unlock(); GetEventManager().OnCreateAnimGraphInstance(this); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphTimeCondition.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphTimeCondition.cpp index 3da55ced3e..e6e9c529df 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphTimeCondition.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphTimeCondition.cpp @@ -90,15 +90,8 @@ namespace EMotionFX if (m_useRandomization) { // create a randomized count down value - if (animGraphInstance->IsNetworkEnabled()) - { - // using a seeded random in order to generate predictable result in network. - uniqueData->m_countDownTime = MCore::Random::RandF(m_minRandomTime, m_maxRandomTime, animGraphInstance->GetLcgRandom()); - } - else - { - uniqueData->m_countDownTime = MCore::Random::RandF(m_minRandomTime, m_maxRandomTime); - } + uniqueData->m_countDownTime = + m_minRandomTime + (m_maxRandomTime - m_minRandomTime) * animGraphInstance->GetLcgRandom().GetRandomFloat(); } else { diff --git a/Gems/EMotionFX/Code/MCore/Source/Random.h b/Gems/EMotionFX/Code/MCore/Source/Random.h index 55576bb958..d2454af38b 100644 --- a/Gems/EMotionFX/Code/MCore/Source/Random.h +++ b/Gems/EMotionFX/Code/MCore/Source/Random.h @@ -64,22 +64,6 @@ namespace MCore */ static MCORE_INLINE float RandF(float minVal, float maxVal) { return minVal + (maxVal - minVal) * rand() / (float)RAND_MAX; } - /** - * Generate a uniform random float in a range of a given minimum and maximum. - * @param minVal The minimum value of the range. - * @param maxVal The maximum value of the range. - * @result A uniform random floating point number in range of [min..max]. - */ - static MCORE_INLINE float RandF(float minVal, float maxVal, unsigned int seed) { AZ_UNUSED(seed); return minVal + (maxVal - minVal) * rand() / (float)RAND_MAX; } - - /** - * Generate a uniform random float in a range of a given minimum and maximum. - * @param minVal The minimum value of the range. - * @param maxVal The maximum value of the range. - * @result A uniform random floating point number in range of [min..max]. - */ - static MCORE_INLINE float RandF(float minVal, float maxVal, LcgRandom& rand) { return minVal + (maxVal - minVal) * rand.GetRandomFloat(); } - /** * Generates a uniform random normalized direction vector, using floats. * @result A uniform random direction vector with a length of 1.