Hi! I have a spinning physics body which I would like to mainly stop spinning if affected by another object. I have two issues which I have struggled to find a solution to:
- The object spinning slows down smoothly, until it comes to a very abrupt stop. The sudden complete stop is too early, and looks unnatural for my use case. Is there some parameter which can be tweaked to affect this behavior?
- I cannot seem to affect the angular damping below a certain point. For example, if I would like for the object to spin forever until affected by the friction of another object. In the example I have tried
setAngularDamping(0), but it still slows by itself.
I am using the HavokPlugin, and initiate the spin with
setAngularVelocity. Here is the playground example: https://playground.babylonjs.com/#5JM0VW#3
Thanks in advance!
Hi @Buddeh and welcome to the forum
I’ve never seen such thing. Maybe @eoin has some tips here?
OK, two things!
The object spinning slows down smoothly, until it comes to a very abrupt stop. The sudden complete stop is too early, and looks unnatural for my use case. Is there some parameter which can be tweaked to affect this behavior?
This sudden stop is the deactivation (or sleeping) behaviour built into the physics engine, which stops simulating bodies which have stopped moving (or nearly stopped) - it’s possible to disable this behaviour per-body; check out lines 51-54 here:
This is an unofficial, unsupported way to disable the setting, as it isn’t currently exposed in the
physicsBody properties, it’s on our list to add someday soon, but the above should work if it’s critical for your use-case.
I cannot seem to affect the angular damping below a certain point.
Nice catch! We have a default, small amount of angular damping per body for stability and it looks like we have a bug where that was still being applied, even if you set a lower one. I’ll get this fixed in the next plugin update.
Thanks @Cedric and @eoin !
Disabling the deactivation-behavior definitely worked for my use case! It is currently only needed for one object in the scene. I still need it to stop at some point, but I can handle this by stopping/deactivating it manually after it goes below a certain threshold for angular velocity. Unless the built-in stop-threshold is also exposed as a parameter, in which case I could just use that
Regarding the angular damping issue - the current angular damping is OK for my use case, but I’m sure there are cases where lower (or even 0) damping is needed. It’s great you’re looking into it!
Once again, thanks a lot for your help!