질문에 참조된 게시물: [How to rotate a character toward a target during a root motion montage without using Motion [Content removed]
Hello,
I’ve run into a difficult issue while implementing a feature and would like to ask for your help.
1. Goal:
I want to maintain the root motion Translation from an animation montage, while overwriting only the Rotation in real-time to face a target every frame.
2. Methods Tried:
To implement this feature, I created a custom class (FMDRRootMotionSource_FaceTarget) that inherits from FRootMotionSource. Within its PrepareRootMotion function, I implemented logic to get the original root motion translation value using UAnimInstance::ConsumeExtractedRootMotion, calculate a new rotation to face the target, and set the final RootMotionParams.
To manage this FRootMotionSource, I created a custom Ability Task (UMDRAT_ApplyRootMotionFaceTarget) that inherits from UAbilityTask. While the task is active, I added logic to prevent control authority conflicts:
Set bUseControllerDesiredRotation and bOrientRotationToMovement on the CharacterMovementComponent to false.
3. Current Phenomenon:
Despite implementing all of the above, the character’s rotation is not being controlled by my RootMotionSource. Instead, the character still snaps instantly to the direction of movement at the start of the dash.
(Through debugging, I have confirmed that the PrepareRootMotion function is being called correctly every frame.)
Attached Files:
FMDRRootMotionSource_FaceTarget.h
FMDRRootMotionSource_FaceTarget.cpp
UMDRAT_ApplyRootMotionFaceTarget.h
UMDRAT_ApplyRootMotionFaceTarget.cpp
UMDRGA_Dash.cpp (The part that calls the Ability Task)
I would appreciate any advice on the potential cause of this issue or alternative solutions. If you’re able to provide a small code sample demonstrating the correct approach, it would be greatly appreciated. Thank you.