timetocode Posted November 24, 2018 Share Posted November 24, 2018 I'm having some issues rotating a bone while any other animations are playing. No rotation occurs until I stop/disable all of the animations that involve the same skeleton. For example this code will rotate the torso, but only if the animations aren't playing. scene.registerBeforeRender(() => { skeleton.bones[1].rotate(BABYLON.Axis.Y, 0.01, BABYLON.Space.LOCAL) }) ... var idleAnim = scene.beginAnimation(skeleton, 0, 89, false); // set to true to stop rotation https://www.babylonjs-playground.com/#IQN716#38 It may seem like it is because the animation has a conflicting position for the bone but I'm pretty sure that isn't why. I've made a separate model that only has animated legs, and I can't turn its head bone while the legs are moving. It does appear to be possible though: https://www.babylonjs-playground.com/#11BH6Z#92 This pg dates back to before babylon had bone.rotate() and it does everything manually via linear alg. Any idea what I'm doing wrong? Quote Link to comment Share on other sites More sharing options...
timetocode Posted November 25, 2018 Author Share Posted November 25, 2018 So I think I've approximately isolated this behavior. bone.rotate(...) has no effect on a mesh that is experiencing an animation, I'm not sure if this is a bug . Example: https://www.babylonjs-playground.com/#11BH6Z#377 this guy's head should be spinning around, but it won't rotate unless the animation is stopped. Code like this does work though: var initMat = skeleton.bones[7].getLocalMatrix().clone(); scene.beginAnimation(skeletons[0], 0, 100, true, 1.0); var angle = 0; scene.registerBeforeRender(function () { var mat = skeleton.bones[7].getLocalMatrix().copyFrom(initMat); mat.multiplyToRef(BABYLON.Matrix.RotationX(angle), mat); angle += .01; skeleton.bones[7].markAsDirty(); }); And here's a PG showing rotation of a torso (using the above technique) while two blended animations are playing... which amazing that it all works together!! https://www.babylonjs-playground.com/#IQN716#39 Is this intentional that this works? I ask only because depending which bone is rotated, it'll bug out and the character will sink into the ground. But rotating the first couple torso/vertebrae bones and the head bone produce the desired effect. My problem is that even with this technique nothing happens to my models. If any animation is playing, then I cannot control the torso or hip bone. I've tried starting/stopping my animation and its as if my character is in two entirely different states. When the animation is playing all I can see is the animation. When the animation ends my guy's body parts are spinning. Maybe I've just done something inappropriate with the bones of my rig: There's a nesting of bones such that root moves the whole mesh, upper moves just the torso+arms, lower moves the pelvis and legs. I thought this would be ideal for a first person shooter where the hips face the direction being traveled in while the torso faces the direction being aimed in. But maybe these nested bone relationships aren't okay? I'm going to make a new post asking for some model samples so I can learn more. Quote Link to comment Share on other sites More sharing options...
adam Posted November 25, 2018 Share Posted November 25, 2018 Use setRotation instead. Rotate will rotate the bone from its current location, so playing an animation at the same time is likely to cause issues Sebavan and NasimiAsl 2 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.