- Home /
Floating/freezing rigidbodies
Hello! I have a simple setup in Unity.
I have a plane with some "marbles" (spheres with rigid bodies) floating directly above the surface of the plane. At runtime the marbles drop to the plane and the player can rotate the plane in the horizontal axis' of the plane, and the marble naturally rolls off in the direction gravity would naturally make it roll - when things work. However When things dont work(50 percent of the time), the marble will drop the small distance to the plane, and freeze indefinitely. I can rotate the plane at this point and the rigidbody marble just hovers in place. Sometimes it unfreezes and then falls into infinity. Does anybody know how to fix randomly freezing rigidbody objects?
I would make sure that the marbles is actually beco$$anonymous$$g kinematic and this is the problem by calling a debug.log in your update -
if(rigidbody.is$$anonymous$$inematic)
Debug.Log("rigidbody is kinematic");
wap the code on the marbles ans see whats happening?
Hey thanks. I implemented your Debug log script. It seems the marble is not kinematic. Here is a video I made that demonstrates my issue.
Shot in the dark. Check to see if your marbles are sleeping:
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.IsSleeping.html
If they are, you can reset Rigidbody.sleepVelocity.
Hey thanks. The marbles are in fact - sleeping. I found the sleep velocity being set to 0 didn't fix things. I tried this through the global setting (edit/project settings/physics) as well as declaring it in the individual script.
Right now I am using an awful hack that keeps it awake. if (rigidbody.IsSleeping() )
rigidbody.WakeUp();
Any idea why setting the sleepvelocity to 0 in the project settings isn't keeping the marbles awake? Thanks for your replies so far - Very helpful!
Answer by gimpytspetsnaz · Apr 29, 2013 at 05:45 AM
Thanks buxton. I tried the debug script you proposed. Here is a video explaining my problem in further detail as well as the result of your debug script.
Your answer
Follow this Question
Related Questions
Gravity on a rotating platform 1 Answer
how to make an object fall slowly ? 2 Answers
How can i rotate player when player jump ? 2 Answers
Roof of the builiding (physics) 1 Answer
Funfair simulation help 0 Answers