As title says, I’m trying to apply a force that always point to one direction in global space, no matter how the object rotate. Gravity is a good example, regardless the object’s rotation, it’s always pointing down.
My attempt is converting global direction into local direction then use it in
const globalDirection = new Vector3(0, 1, 0) const localDirection = Vector3.TransformNormal(globalDirection, targetObject.getWorldMatrix().clone().invert())
Is this the right way? If I want to fight off the gravity with this implementation, the object hovers and stay still if the up force is applied at center of mass, but if applied slightly different from center of mass, the object will start to rotate then making unexpected movements.
I made this PG here as an example, where red box hovers and green box moves unexpectedly: https://playground.babylonjs.com/#MFIPKH#9