A problem with changing rigidbody mass in the script

Hi everyone,

I want to know is it possible to change a rigibody’s mass ‘on the fly’ without any side effect?

I was simulating a rigidbody gradually losing its mass in the BGE, but when the obj’s mass is changed in a script, it seems the obj’s acceleration of gravity changed as well.

I made a blend file to demonstrate this problem.
In the file a script is attached to Cube2 to change its mass, and you can see its motion is very different with Cube1, I don’t know what’s wrong here, can anyone explain this?

Thanks!
nemo

Attachments

test.blend (449 KB)

As far as I know changing the mass works only once. After that you get unexpected results. It seems to be a bug.

Yes you’re right! My test shows that the difference shows up right after the second mass change, and it becomes more and more obvious ever since.
I did the test in both v2.62 & 2.63.

It seems to only be for gravity, as in my game with no gravity it works perfectly. It may be a bug with recalculating the required force? In which case changing and then unchanging gravity for a frame may solve it.

Thank you, it does solve the problem.
I put bge.logic.setGravity([0,0,-9.8]) after the mass change, and it seems OK right now.