Obi Official Forum
[Solved] Softbody SetMass issues - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html)
+--- Thread: [Solved] Softbody SetMass issues (/thread-2731.html)



[Solved] Softbody SetMass issues - Tomobodo - 01-02-2021

Hello, when I use SetMass to change mass during game, the softbody get launched in the air so fast it get in NaN coordinates.

My use case is a blob eating, I want to increment the mass of the blob when it eats.

I use SetMass once on instantiation to set initial mass, wich work fine, but once I detect a collision and change the player's blob mass, it get launched in the air.

If I increment mass by some very low value like 0.00001f the blow slowly accelerate upward.

Is there a better way to change mass ?

Thanks


RE: Softbody SetMass issues - josemendez - 01-02-2021

Hi there!

After altering the mass of softbody particles (be it the entire softbody using SetMass(), or on a particle-by-particle basis), you need to recalculate its rest shape. Call:

Code:
softbody.RecalculateRestShapeMatching();

right after setting its mass.

kind regards,


RE: Softbody SetMass issues - Tomobodo - 05-02-2021

(01-02-2021, 08:01 PM)josemendez Wrote: Hi there!

After altering the mass of softbody particles (be it the entire softbody using SetMass(), or on a particle-by-particle basis), you need to recalculate its rest shape. Call:

Code:
softbody.RecalculateRestShapeMatching();

right after setting its mass.

kind regards,

Hello, thanks for your quick answer. 
Regards.