Dear Jedi Council, I stand before you a humble potato with no real grasp of maths, and -1 Häagen-Dazs 500ml for my troubles.
My mission was simple, walk my avatar over to a chair and sit down. I hypothesised all of the ways to achieve my goal. Problem one was that my chair could be any direction, so I created an invisible mesh( prob should have expanded the bounding box for this one but you live and learn) around the chair and on intersection of the player mesh, I rotated the chair towards the player. It only cost me a day.
My potato brain thinks in 360 degrees so initially, I was just thinking I need the angle between the front of the chair and the player position. Eventually, I managed to figure out creating a matrix, and using look to
let lookMatrix = Matrix.LookAtLH( this.chair.mesh.position, this.engine.avatar.mesh.position, Vector3.Up() ).invert(); let rotationQuaternion = Quaternion.FromRotationMatrix(lookMatrix);
But now I know that If I dot product the vectors and then divide by the square root added together then I end up with an angle if I do a arcsign …still don’t get it.
Right-handed vs Left
I think I’m inverting because of the whole left and right thing and blender being in the Right-hand mode and me not going that and building everything without setting the right-hand mode for GLTF things first, doh!
The Story Continues
Anyway, so far, walk over to the chair, chair rotates (it’s not perfect for sure but hey ho), cool!
Build an animation of a little dude sitting on the chair, cool, I thought this probably isn’t going to work because the animation will move the x,z position of the player and the origin will be all messed up, this is 100% what happens.
My question is, what is the right way to think about this getting an avatar to sit on a chair from standing, it’s not as easy as getting them into a sitting position because there is a small jump and x,z move involved to get them into position on the chair. I thought this might be solved by creating a spline in blender and having the player follow it with easing to replicate the jump into the right position.
I’m parenting the player to the chair so when the chair spins back to its starting position we’re pretty good.
I guess what I’m really lost with is the correct flow from blender to Babylon, how do I do in each one.
Also just a massive thank you to this incredible team, and an amazing engine, the fantastic youtube content, I promise I’ve tried to solve this one myself as best I can but I think I’m, missing some of those high school fundamentals to get this right solo.
It feels like the choreography between the player, the animation for sitting, the movement onto the chair is something that is done in blender and not in engine and I am just the consumer of these things.
Did I miss a trick with animation groups, was the correct approach do something with combined animation groups…
Again thank you super humbly, and sorry I couldn’t figure it out on my own.