How to Get Angular Momentum of an Assembly?

I’m simulating friction on a vehicle. Since the friction is applied at the contact point, away from the center of mass, there is also a rotational component. Finding the angular impulse resulting from the friction force in each physics step is trivial (arm x friction * dt). It’s important that I’m not applying an angular impulse that would reverse the vehicle’s angular momentum in the next step. So I need to scale it down according to the vehicle’s angular momentum.
Angular momentum = moment of inertia * angular velocity
Angular velocity is easy to find, but surprisingly I have not found any mentioning of rotational inertia/moment of inertia or tensors in any Roblox documentation.
I’ve seen a handful of Roblox games that simulate vehicle dynamics fairly realistically. Do they write their own matrix and tensor libraries?

I don’t think you can get it from Roblox. I have no experience of this in Roblox, but if I was modelling a vehicle I would start by setting all of the parts to be massless, and then add just one cube as a “physics controller”, you can then give that cube a mass and size that gives you the inertial properties you know and want.

Edit: I see from Constraints cause massless parts to add inertia to assemblies that welding massless parts to the massed part forces an inertia recalc based on the new volume, so this is probably not a useful approach.

HTH

2 Likes

Did you ever figure out a workaround for this? I’m in the same exact boat; trying to clamp my physics forces so as not to flip the vehicle’s velocity sign. This feature was asked for by someone in a major update thread in 2022 and it was seen and liked by some devs at roblox but I guess they never got to it.

Yes, but it’s really convoluted. For clamping angular velocity you would need to know the inertia matrix. What I ended up doing was I created custom physics simulation rather than using Roblox’s physics simulation. For the purpose of vehicle dynamics it works very well, but there’s also the burden of reinventing the universe.

Would this help?
https://create.roblox.com/docs/reference/engine/classes/BasePart#GetVelocityAtPosition

We’re looking for something called an inertia tensor or inertia matrix which is basically a bunch of values that represent an object’s tendency to resist changes in angular velocity about it’s axes. We’re not looking for the object’s linear or angular velocity, we’re looking for the object’s mass distribution which is required to predict how an object will react to forces that will change it’s angular velocity. I imagine this information exists under the hood and roblox just needs to expose it to us. I hope someone at roblox can get around to making it happen for us soon. I think for now I’ll just do what @LostShedGames suggested and use an object with a known inertia tensor and just use a script to set the vehicle body CFrame equal to the CFrame of this “physics controller” object to avoid any physics recalculations happening to this “physics controller” due to weld constraints.

OK I took that bug report at face value, but I have now updated it and re-run it.

inertia_test.rbxl (58.3 KB)

Here you can see two blocks with an angular impulse applied to them every heartbeat (I’ve removed gravity to keep the interaction simple). You can see that having a massless part welded to the main block does not affect its inertia. If you take the lone block and increase its size a little then this does affect its inertia as expected.

So basically, roll back to what I initially said and use a single massed block to tune your inertia and then weld your massless visuals to it.

I hope I got that right as I am bored of this now :rofl:

1 Like