ozRocker Posted May 14, 2016 Share Posted May 14, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 15, 2016 Share Posted May 15, 2016 Do you think it could be possible to identify the key when your body is in the air and then only translate at that time? Quote Link to comment Share on other sites More sharing options...
dbawel Posted May 15, 2016 Share Posted May 15, 2016 @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 Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 15, 2016 Author Share Posted May 15, 2016 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 Quote Link to comment Share on other sites More sharing options...
dbawel Posted May 15, 2016 Share Posted May 15, 2016 @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. Quote Link to comment Share on other sites More sharing options...
adam Posted May 16, 2016 Share Posted May 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 16, 2016 Author Share Posted May 16, 2016 I'm confused. How can a parent bone affect the permanent position / rotation of the mesh? Quote Link to comment Share on other sites More sharing options...
adam Posted May 16, 2016 Share Posted May 16, 2016 Because when you move a parent, the children follow and your children move the mesh. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 16, 2016 Author Share Posted May 16, 2016 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 Quote Link to comment Share on other sites More sharing options...
adam Posted May 16, 2016 Share Posted May 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
adam Posted May 16, 2016 Share Posted May 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
adam Posted May 16, 2016 Share Posted May 16, 2016 http://www.babylonjs-playground.com/#1GEYSB#12 Quote Link to comment Share on other sites More sharing options...
adam Posted May 16, 2016 Share Posted May 16, 2016 http://www.babylonjs-playground.com/#1GEYSB#13 ozRocker 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.