rapier.js
rapier.js copied to clipboard
Allow changing velocity scaling factor on each axis individually
A feature request to add linear and angular velocity scaling factor on a rigidbody, which would allow to control each axis individually:
For example, in Bullet engine:
void btRigidBody::setLinearFactor(const btVector3 &linearFactor);
void btRigidBody::setAngularFactor(const btVector3 &angFac);
Thank you for this feature suggestion. What are some concrete use-case for these factors?
If you are looking for the ability to lock the rotation and/or translation movements of a rigid-body, you can already use RigidBodyDesc.restrictRotations
, RigidBodyDesc.lockRotations
, and RigidBodyDesc.lockTranslations
.
@sebcrozet to be honest, I don't have many examples, when I would use it other than just to lock some axis. I think the only time I used it with interpolation between 0 and 1 was when there was a game with wind gusts, where a wind would suddenly "blow" from some direction at varied strength, dampening the player controller movement at some direction. I guess the same could be achieved by applying a force on the controller.
I stumbled upon this while integrating Rapier with PlayCanvas, which currently is integrated with Ammo. The Editor exposes those properties:
Setting one of them to 0 would effectively "lock" the axis, which is a way to do it in Ammo. Not too critical of a feature, I suppose, as I can probably output a message to user that only 0 or 1 is supported when using Rapier backend.
In a casual game of bowling, I have some hazards on the road that imped the ball's travel. For example, water or sand, which affect the ball's movement in a single or both axii. The way it works is that the ball multiplies own factors with whatever it traverses through. I think it would be a good case for enabling linear/angular factors here. For now, I have to code in the factors separately for each type, verify the obstacle type the ball is going through and manually adjust the velocity based on the factors multiplication result.
Edit: Actually, thinking about it, this is not how the linear factor should be used. I mean it can, but then it is a decision of mine, rather than the physics engine. One's linear factor should not affect the other one's. It's probably related to the friction factors rather, but I think we can't change friction on each axis individually.