Edit the mass
-
- Posts: 3
- Joined: Wed Feb 27, 2013 1:28 pm
Re: Edit the mass
The mass of a body is determined by the density of the fixtures attached to it. One way to set the mass to a specific value is to scale the density of all fixtures equally.
Unfortunately there are no body::getMass or fixture::getDensity functions exposed to script at the moment, otherwise it would be quite easy to write a script to do this. I will add these functions in the next update.
Unfortunately there are no body::getMass or fixture::getDensity functions exposed to script at the moment, otherwise it would be quite easy to write a script to do this. I will add these functions in the next update.
Re: Edit the mass
In v1.2 the script fixture class now has setDensity and setMass functions, and the body class also has a getMass and setMass functions, so this is now possible.
I kinda forgot about adding the mass as a first class property of bodies (to display and edit in the properties panel), but then again it's not actually a first class property of bodies anyway. Maybe this could be done in the next update.
In the meantime you could add a script like this to your action menu:
I kinda forgot about adding the mass as a first class property of bodies (to display and edit in the properties panel), but then again it's not actually a first class property of bodies anyway. Maybe this could be done in the next update.
In the meantime you could add a script like this to your action menu:
Code: Select all
float mass = queryNumericValue("Mass:");
body[] bodies = sb();
for (uint i = 0; i < bodies.length; i++)
bodies[i].setMass(mass);
Re: Edit the mass
Mass has been added in the properties panel as a first-class member of bodies in v1.3.