- Home /
How to stop RigidBody properties from changing dynamically at runtime
I'm very new to Unity, and I'm just playing around with a dice rolling simulation. I have a single cube with a rigid body and the StandardAssets DragRigidbody script associated with it. When I run the preview, I can drag the cube around just fine, and if I fling the cube it flies off in that direction and rolls around just like I would expect it too.
A problem occurs when I duplicate the cube and run the preview. Both cubes can still be dragged around, but they cannot be flung. If I try to fling either of them, the moment I let go of the mouse button the cube stops moving completely. If it happens to be in the air at the time, then it floats back down very, very slowly as if there is almost no gravity.
I actually do know what's causing this behavior, but I don't know why it's happening. These are the Rigidbody properties for the cube(s) before I run the preview (the values that I want):
Mass: 1
Drag: 0.5
Angular Drag: 0.5
// The rest are defaults
...but when I run the preview with more than one cube, I can see the values change as soon as I drag a cube to these:
Mass: 1
Drag: 10
Angular Drag: 5
So this is what's causing the loss of fling functionality. The values don't change with only one cube, so why do they change with multiple cubes?
Answer by RTF · Feb 27, 2014 at 05:22 PM
It turns out that the Drag and Angular Drag properties of the DragRigidbody script associated with each cube were overriding the same properties of each Rigidbody. The DragRigidbody script values were 10 and 5 for Drag and Angular Drag, respectively, and I just never noticed them before.
I still don't know why I wasn't having problems with only a single cube though. In any case, setting the values of the DragRigidbody script to the same as those in Rigidbody got things working.
Your answer
Follow this Question
Related Questions
problem with dragrigidbody 0 Answers
how to drag gameobject up to 180 and down to -180 using mouse drag? 0 Answers
Drag Rigidbody 2 Answers
modifying dragrigidbody script 0 Answers