1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

rotating a rootmotion pawn

Discussion in 'Programming' started by johnnymak, Jan 24, 2006.

  1. johnnymak

    johnnymak New Member

    Joined:
    Mar 28, 2005
    Messages:
    22
    Likes Received:
    0
    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
     
  2. neai

    neai ^^

    Joined:
    Jan 6, 2006
    Messages:
    42
    Likes Received:
    0
    Try rotating the location delta before applying by actor rotation.
    IIRC it looks like this: "RotatedDelta = GlobalDelta >> Rotation;"
     
  3. neai

    neai ^^

    Joined:
    Jan 6, 2006
    Messages:
    42
    Likes Received:
    0
    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).
     
  4. johnnymak

    johnnymak New Member

    Joined:
    Mar 28, 2005
    Messages:
    22
    Likes Received:
    0
    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.
     
  5. johnnymak

    johnnymak New Member

    Joined:
    Mar 28, 2005
    Messages:
    22
    Likes Received:
    0
    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.

    I
    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.
     
  6. johnnymak

    johnnymak New Member

    Joined:
    Mar 28, 2005
    Messages:
    22
    Likes Received:
    0
    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.
     
  7. neai

    neai ^^

    Joined:
    Jan 6, 2006
    Messages:
    42
    Likes Received:
    0
    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?
     
  8. johnnymak

    johnnymak New Member

    Joined:
    Mar 28, 2005
    Messages:
    22
    Likes Received:
    0
    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!
     

Share This Page