[Solved] Axis specific Velocity Reduction - issue possibly in setLinearVelocity/math/local global

Hi. I have an actor with a physical body. I apply forces to it and I want to “simulate” drag. I tried to getLinearVelocity, transform it into actors coordinates, *modify it, transform it back, and setLinearVelocity back.
This afaik completely works, if I modify it as a whole (lerp to (0,0,0) vector).

But when I try to lerp x, y, z with different rates, it works only if I don’t spin my ship. When I try to spin more aggressively, I am able to completely change my direction (more than 90° - which should be impossible).

Blue arrow is the original linear velocity, the red/green arrow is the current linear velocity. This is how it is supposed to work all the time:

](filedata/fetch?id=1804176&d=1598228930)
You can see how it reduces local Y velocity and keeps local X velocity. (Video 20-30s here https://youtu.be/p-MFSjqyUEI?t=20)

But when I heavily rotate (and only with different values per axis), I am pretty easily able to produce ‘impossible’ state:
Broken3.png](filedata/fetch?id=1804177&d=1598229016)
It should be impossible to reduce the blue vector to the red one, yet this happens.

My code is this (box is the root of the actor) and works if I set all the alphas to the same value:

](filedata/fetch?id=1804179&d=1598229074)
(yaw control here):
yawCtrl.png](filedata/fetch?id=1804180&d=1598229523)

You can see the problems in the video here, at 50s mark: https://youtu.be/p-MFSjqyUEI?t=50

I’ve tried pretty much everything I could think of, but I didn’t solve it yet. Could anyone help me, please? I struggle with it for quite some time now, which is why I have that ground texture, these arrows etc. I am unable to understand why this keeps happening.

Update: I’ve added debug box (the current linear velocity should not be able to escape said box), yet is does just that with ease. I’ve tried to use AddForce instead of changing the velocity directly, I’ve tried to add two forces separately for each axis, I’ve rewired the control logic so that I can be sure of the order of it happening, yet the problem still persists.

You can see how the velocity, that should just be reduced leaves its possibility space:

What am I doing wrong? I don’t get it. At all :frowning:

And I’ve found the culprit:


The issue was that each tick, the ship could be rotated differently, so the possibility space of the reduced vector changes. Violet velocity shows how previously impossible future velocity becomes possible, so with the optimal ship rotation, I am able to turn the vector fully around.

The sad thing is, that this actually isn’t an issue. It should act exactly like that. Car moving South will move north if only steering will be applied. It just seems counterintuitive - possibly because you could do things like these only in extreme cases, like with a car, where the sideways slowdown is incredibly high, but the forward slowdown is almost non-existent at lower speeds).