A customer noticed that root motion did not mirror properly when using montages.
The issue is that the root motion mirroring code is only called from FAnimSync::TickAssetPlayerInstances .
The following code was suggested by the customer in UAnimInstance::Montage_Advance after MontageInstance->MontageSync_PostUpdate();, A simplified version in another location might be more appropriate.
MontageInstance->MontageSync_PostUpdate(); if(RootMotionParams != nullptr && !AnimInstanceProxy->Sync.GetUngroupedActivePlayersRead().IsEmpty()) { FAnimTickRecord TickRecord = AnimInstanceProxy->Sync.GetUngroupedActivePlayersRead()[0]; if (TickRecord.MirrorDataTable) { FTransform InTransform = RootMotionParams->GetRootMotionTransform(); if (bUsingBlendedRootMotion && !RootMotionBlendQueue.IsEmpty()) { InTransform = RootMotionBlendQueue.Last().Transform; } FVector T = InTransform.GetTranslation(); T = FAnimationRuntime::MirrorVector(T, TickRecord.MirrorDataTable->MirrorAxis); FQuat Q = InTransform.GetRotation(); Q = FAnimationRuntime::MirrorQuat(Q, TickRecord.MirrorDataTable->MirrorAxis); FVector S = InTransform.GetScale3D(); FTransform MirroredTransform = FTransform(Q, T, S); if (bUsingBlendedRootMotion && !RootMotionBlendQueue.IsEmpty()) { // Defer blending in our root motion until after we get our slot weight updated FQueuedRootMotionBlend& LastQueuedRootMotionBlend = RootMotionBlendQueue.Last(); LastQueuedRootMotionBlend.Transform = MirroredTransform; } else { RootMotionParams->Set(MirroredTransform); } } }
See attached diff for the full set of changes
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-171670 in the post.
0 |
Component | UE - Anim - Gameplay |
---|---|
Affects Versions | 5.1 |
Target Fix | 5.6 |
Created | Dec 2, 2022 |
---|---|
Updated | Mar 4, 2025 |