Community Forum

getMass script function

Forum Overview >> Farming Simulator 2011

CategoryFarming Simulator 2011
Created20.10.2010 23:57


B. Benjamin (Unknown) 20.10.2010 23:57
hello,

I'm working on a mod for LS 2011. This one uses "getMass" to get the mass of a dynamic compound node.
this is the code I'm using :
self.BoggedPart = {};
self.BoggedPart.Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.BoggedPart#index"));
self.BoggedPart.Mass = getMass(self.BoggedPart.Node);

The log gave me back this error :
PhysX invalid parameter: Actor::updateMassFromShapes: density or total mass must be nonzero!
(f:\p4sw\sw\legacy\physx\experimental\PhysX_2.8.3\novodex\SDKs\Physics\src\NpActor.cpp:122

If I change the script, using this instead :
self.BoggedPart = {};
self.BoggedPart.Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.BoggedPart#index"));
self.BoggedPart.Mass = 0.1;

the script works.
So, my question is : is "getMass" still working in LS2011 ?
The object's mass in the editor is 0.10126. Does "getMass" thinks that 0.1 = 0 ?
The script was working in LS 09.

Kinda strange... ^^
Thanks for your help,

Bayn

Stefan Geiger - GIANTS Software 02.11.2010 12:24
getMass still is working. I think your problem is caused by setting the mass later, with a value of 0.
The problem might be, that call getMass in the load function of the vehicle. Since the physical object might not be loaded at this thime, the mass might be 0.

You should get the mass in the update function, and there only when it was entered the second time. There is a variable called firstTimeRun, which is true, if this is the case.

Furthermore you should not call getMass on a client, but only on a server or in singleplayer mode.

So you should have something like this:

In the load function:
self.BoggedPart.Mass = nil;


In the update function:

if self.firstTimeRun then
if self.isServer then
if self.BoggedPart.Mass == nil then
self.BoggedPart.Mass = getMass(self.BoggedPart.Node);
end;
end;
end;



and for the setMass
if self.BoggedPart.Mass ~= nil then
setMass(....);
end;



B. Benjamin (Unknown) 05.11.2010 23:53
Hello Mr Geiger,

Thanks a lot for your help. I'll have a closer look at all that asap.

Regards,
Benjamin

Loki Laufeyson (loki_79) 11.06.2020 12:02
Sorry to ressurect an old thread, but I can't see a button to create a new thread.

"Furthermore you should not call getMass on a client, but only on a server or in singleplayer mode."

Can anyone point me in the right direction for how the client can know the mass of an object correctly in multiplayer. Should I create an Event function to send the object handle to the host, who can then getMass() and return the value? Is there an easier way? It is hard to debug this with only one computer.

Edit: I found that 'lastFoundObjectMass' is correct on the client, but I still need to get the splitShape type - is there a synchronised variable for this?


Note: Log in to post. Create a new account here.