My goal is to set the angular velocity of a golf ball after a golf swing, while still utilizing as much of ageia’s physics as possible. I’ve tried setting the value manually: myRigidbody.angularVelocity, and I’ve tried adding a torque myRigidbody.AddTorque(…) and in both cases it seems as though the angular velocity gets stomped by the next call to fixed update. Do I need to keep track of the desired angular velocity myself? How can I convince Unity that the ball is initially spinning at an angular velocity of my choosing?
If you set an object’s angularVelocity directly, it will keep that angular velocity until something else changes it, like hitting an object. Also angular drag will slow down the angular velocity over time, depending on what that is set to. It won’t just stop by itself, though, so make sure you’re not changing it in another script or something.
So I double checked all my scripts and nothing else is setting angular velocity but the one place. Angular drag is 0.1 for the golf ball. I’ve been testing with an upper limit of 15000 rpm which translates to 1570.79 radians / sec ( 15000 rev/min * 2pi radians/rev * 1 min/60 sec). When I run the program, the first frame I get the appropriate angular velocity, but every successive frame says I have an angularVelocity of 7. The only thing that I can think of, is that somehow 7 is a “reduced” form of the angular velocity; since there’s no way a person could discern the rotation by watching the screen (due to limitations in framerate and our eyes), perhaps unity makes it actually spin at some velocity that we would perceive as being the same as the requested velocity? All that to say, I still don’t know how my angular velocity is getting altered. Any ideas are greatly appreciated!
Oh, that…Edit → Project Settings → Physics, specifically, “Max Angular Velocity”. Sorry, I thought you were saying the angular velocity was being set to 0…that was my interpretation of “stomped”, anyway. You can override that for individual objects if you don’t want to change the default.