Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Softbody SetMass issues
#1
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
Reply
#2
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,
Reply
#3
(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.
Reply