
I'm working on a skateboard simulation using Ammo.js, the javascript version of Bullet, and my objective is for the skateboard to do a varial (rotate around the local Z_forward axis and the local Y_up axis at the same time). Here's a slow mo video of a varial for reference: https://www.youtube.com/watch?v=K1FHvxXh5NU
In my simulation I'm using a btRaycastVehicle as the skateboard and I've been successful at using torque to make the skateboard rotate around the Z axis or the Y axis, but only when torque is applied to one of those axis at a time. If I apply torque to both the Z and Y axis it results in a spiraling motion, which is undesired. You can see what I mean by going to the simulation (https://skateboard.workroomvr.com) and once in the park press space to jump and then hold H and Y at the same time. I've searched the web for solutions to this problem and many sources state that a rigid body (RB) can only rotate around 1 axis at a time, although that axis can shift. That appears to be exactly what happens when I apply a combined torque to the skateboard.
So the only potential solution I've found (https://answers.unity.com/questions/375 ... eousl.html) is to use two different objects parented together and rotate each one around a single axis. That solution made sense to me but when I tried to achieve that with Bullet rigid bodies, I got stumped. I found no way to create a parent-child relationship between two rigid bodies. If you can please let me know but even so, I still foresee a problem with this solution because of the relationship between the parent RB (lets say it would receive the Y axis torque), the child raycastVehicle RB (receive all driving inputs and the Z axis torque), and the graphic skateboard (copying transform of raycastVehicle RB). Then I thought about making the raycastVehicle RB be the parent, have a child RB (for Y axis torque), and make the graphics skateboard copy the transform of the child RB. Makes some sense to me but that will result in the problem of the graphics skateboard and the raycastVehicle RB having separate transforms, which would eventually cause undesired effects.
Other thoughts and solutions I tried:
I looked into using compound shapes but I believe I need 2 rigid bodies to achieve the solution outlined above, since I need to apply different torque to both rigid bodies.
I've also tried using p2p, hinge, and 6dof constraints between the raycastVehicle RB and another RB to somewhat act as a parent-child relationship, but I couldn't make sense of how to put together a proper solution with that method.
I'm to the point now that I'm thinking I may have to resort to doing some sort of graphics-only animation based implementation of the varial (simple to create in blender) but I really want to figure out a physics implementation if possible, and I have a feeling it's not impossible.
Could anyone provide some insight on how I could accomplish my objective using physics? If not, would you go the route of creating an animation in blender and applying that to the graphics skateboard? My concern with that route is the graphics and physics will diverge when the animation is occurring.
Is there something I'm totally missing here? Maybe a way to achieve my objective without torque or a graphic animation?
Thanks in advance for any help!