physicsBody: angularDamping/linearDamping question

https://www.babylonjs-playground.com/#UFVU18#177
(erf)

Hi guys. In Cannon, located natively on mesh.physicsImpostor.physicsBody… there IS .linearDamping and .angularDamping. See lines 62 and 63. EITHER will work for a damping system for the box, because it has both linear and angular movement as it hinge-spins around it’s cylinder buddy.

BUT… this is not what you seek. You seek an angular damping on the hinge joint itself. I went deep-diving into Cannon’s joints… looking for things… and found nothing… except… using a setMotor(speed, maxForce)… where speed (neg or poz value) is mostly for setting (counter-) spin direction, and maxForce sets the amount of allowed “backspin”… which is very important for brakes. We don’t want them to stop immediately. We want them to “frictionize” the hinge until spin comes to a gentle stop.

SetMotor worked… but… I couldn’t determine WHEN the motor’s counter-force… stopped the hinge from spinning. And so, I couldn’t tell WHEN to shut-off the motor… and thus… after stopping the spin… it started slowly spinning in the opposite direction. Erf. Using an opposite-direction-running WEAK maxForce motor… to dampen the spin… works… but it comes with hassles.

Although damping methods like lines 62/63… are working… they are actually damping the impostor, and NOT the hinge pivot axis. So they are “cheating”… and not what Holger is asking-for. Oh well… sorry.

Umm… this playground just spins-up the hinge… and then 3 seconds later… applies the brakes, and switches the background color. It works pretty good, I guess. LinearDamping seems more powerful than angular, in this demo. Damping values of .9999 etc… really slams-on the brakes (adds much resistance). .3 and below… hardly noticeable.

Sorry for the messy playground. Holger/others… if ya got questions/comments about it… just holler… I don’t mind yapping. :slight_smile: I’m not sure if this method will work in Oimo or Ammo physics engines… maybe. Probably not. :slight_smile: Party on.

2 Likes