Jump to content

Root motion problem


ozRocker
 Share

Recommended Posts

I have an avatar that walks around using standard walk animations.  I did the usual process of removing translation of Z position changes on the hip (root) bone and moving them by normal Babylon.js translation functions.  There's no problem here because walking is straight-forward and easy to emulate.  However, I've added flying animations and things aren't so simple.  Before my avatar flies he jumps into the air.  I cannot use simple Babylon.js translation to mimic the position changes when jumping because he crouches down first then springs up into the air.  Same with landing.  Is there a way to enable root motion for this?  What would be ideal is to leave the jumping animation as it is and have changes to the hip bone in Y location to affect the actual mesh position then when he starts flying around he will do that from where the jump animation ended.  Same with landing.

 

Link to comment
Share on other sites

@ozRocker -

@Deltakosh is providing the best answer I've found, which is either to identify the end key of your jump motion to begin Y translation in world space; or you can create a delay in miliseconds once the jump motion is initiated as long as you know the "time" it takes for the motion to complete, as I assume this is a constant. I hope we both understand the question and aren't over simplifying.

DB

Link to comment
Share on other sites

I don't think that will work cos root motion is not enabled on the jump. I can't just continue the movement from the jump like that because the position of the hip bone will reset back to zero on the next animation. The avatar will snap back to hip position zero. Of course if root motion was enabled I would simply blend the jump anim into the fly anim

Link to comment
Share on other sites

@ozRocker- I think I understand your problem now. In my opinion, the best (and possibly only) way to accomplish this is to parent the root joint and animate the parent when needed. From your question, I thought we might be missing what your issue is - as I assumed you we're already animating a parent of the root, and not the root itself, as this will never be an easy task - as if the root already has animation, there is generally no constant with which you can work from. Transforming a parent also allows you to get transform info from the root such as acceleration which you can then mathematically measure and apply in real time to the parent's transforms. Just beware of dependancies, as the math needs to reflect the transforms of its own parent, and not mathematically driven by its child's transforms.

Personally, if I have a transforming skeleton, I NEVER add keys to existing skeleton animation other than blending, due to the additional transform constaints which are native to bone transforms to create an IK chain - including parenting - once the skeleton is imported into BJS. Perhaps Babylon might support a general method of IK one day? I can't imagine DK and DAV haven't considered this.:) However, I doubt many people other than myself would take advantage of this right now unless there was an extension written to directly retarget bone animation in Babylon. So I don't see the priority right now.

DB

EDIT - Actually, IK might be useful as we could then build simple functions to incorporate physics or simulate phyisics into skeleton animation, such as to simulate gravity on skeleton chains by offsetting the transforms of an end effector in time.:)

Link to comment
Share on other sites

This might just be repeating what dbawel suggested.  I would try adding another bone to your model in blender (maybe place it on the floor) and set it as the parent of the hip bone, making that your new root bone.  Now you can select which translations you wish to remove from the hips rather than removing all.

Link to comment
Share on other sites

7 minutes ago, adam said:

Because when you move a parent, the children follow and your children move the mesh.

But how does that permanently move the mesh? mesh.position.y won't change because of bone animation. It may appear the the mesh is moving upwards but that's the bone pushing it that way. As soon as the animation repeats or transitions to another it will snap back

Link to comment
Share on other sites

38 minutes ago, ozRocker said:

As soon as the animation repeats or transitions to another it will snap back

It shouldn't if you are using animation blending.  Not allowing the animation to transition mid-jump would also help.

Is moving the y position of the mesh necessary for your jump animation?  If so, you will need to use Deltakosh's suggestion.

Link to comment
Share on other sites

I just watched your video again and the fly animation would be an issue with the new root bone method.  I would definitely go with Deltakosh's answer.

Edit:  You might need to use a combination of the suggested answers.  The extra root bone could help solve the crouching before the jump.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...