My ball keeps freezing when it sits still, and changing gravity direction does not budge it. I’m thinking this may be “sleep” related and easily solved, but I can’t find the documentation on what sleep is, and how it works.
From what I know, sleep is just a way for the physics engine to skip most calculations for objects that aren’t moving, thus speeding things up a lot if objects are lying around doing nothing. If you knew that no objects would ever need to sleep, I guess one way to get around the problem would be to set Sleep Velocity and Sleep Angular Velocity (in the physics manager) to 0. Objects need some kind of force acting on them to wake up, but you’re right, changing gravity won’t do it, it has to be some other object or through scripting. You can check for sleeping objects…maybe something like this:
if (rigidbody.IsSleeping() ) {
rigidbody.WakeUp();
}
Thanks. Actually I found WakeUp and was using it to solve the problem–but I’d still be interested to learn more. The sleep velocity solution might be better/less overhead, since we only have the one object in our game anyway.
I don’t think there’s anything more to it than that, really, although someone can tell me if I’m wrong. With one object, yeah, I’d just change sleep velocity to 0.
I didn’t find a native method that does this and other things I’m interested in.
if this is really the case, which to my knowledge it is, you’ll have to create an architecture that will achieve this.
the architecture should give you the ability to place code somewhere that would be executed after the physics simulation and before any of the FixedUpdate functions execute. you would there check if the object was sleeping and now is not to fire an event OnWakeUp (), and check the reverse to fire OnSleep (). in this way you will receive and handle these events after OnCollisionEnter (),… and before FixedUpdate ().
I’m in the way of creating an architecture for this, but it will have 2 main restrictions:
1- all your scripts should be of type/subtype ExtendedMonoBehaviour (under development)
2- you are not allowed to define any method with the name FixedUpdate. instead you will place your fixed frame code in a method called OnFixedUpdate.