View Full Version : rotating a rootmotion pawn

24th Jan 2006, 06:06 PM
i have a rootmotion non player pawn that updates its location based on the animation data (which moves away from (0,0,0) a lot. using move(rootdelta) or setlocation(prior location + delta) works fine for moving tha pawn.
however now i'd like to be able to rotate the pawn at the start of a new anim so it travels in another direction using the same animation data.
if i use setrotation(new yaw), the location data stays the same even if the pawn is facing new direction.

can anyone suggest a way to rotate a rootmotion pawn and have the location data move relative to the new heading?

i tried setbonedirection() and setbonerotation() on the root bone Bip01. one had no apparent effect though the logged yaw did change, one rotated the pawn on multiple axis, not just vertically, so it kept flipping around to face all over the place each new anim (not sure if this is euler angle problem?).

any suggestions really appreciated

24th Jan 2006, 06:51 PM
Try rotating the location delta before applying by actor rotation.
IIRC it looks like this: "RotatedDelta = GlobalDelta >> Rotation;"

24th Jan 2006, 07:01 PM
The unexpected rotation might be caused by rotating bone in local space - bone's rotation most likely points in direction of the next bone in chain.

Try SetBoneDirection and SetBoneRotation with Space=1 (World space).

24th Jan 2006, 07:44 PM
thanks neai
yes default Space=0 is model space. i will try world space. in anim browser bone seems to point vertically to next bone so i thought it might be ok. cheers.

25th Jan 2006, 12:19 AM
setbonerotation() seems to ignore space and applies to bone space always. SetBoneDirection() still has no effect.
setbonerotation() works fine now to rotate the pawn.yaw and give it new heading (silly me) but the setlocation() animation still follows the original paths.

IIRC it looks like this: "RotatedDelta = GlobalDelta >> Rotation;"
I probably do need to have a global rotation offset to apply before the locationdelta as you say. i'm not sure how to apply this though if the original pivot point (0,0,0) is moved each tick with the animation.

25th Jan 2006, 06:03 PM
i notice in normal walking physics when i rotate the pawn, the animation plays out in the new direction fine. can you please suggest a function or maths to calculate a global pivot of the animation location data. got me stumped. any hints would be really great.

25th Jan 2006, 10:30 PM
I don't know how your root motion script works, how the delta's are calculated, etc. Can you post the code or explain it in detail?

26th Jan 2006, 12:29 AM
hi neai
actually your above suggestion
"RotatedDelta = GlobalDelta >> Rotation;"
seems to work fine. i just didn't quite get it and had to swap pitch and yaw for setbonerotation() vs GlobalDelta>>Rotation.
i am using GetRootLocationDelta() in Tick() and then movesmooth(rootdelta) to change the location.
thanks a lot!