- Home /
Does an asleep rigidbody mess with the OnTriggerEnter function?
void OnTriggerEnter(Collider col){
Debug.Log (col.name + " is in the volume");
}
The code is extremely unexciting, but the collider name isn't even displayed. I noticed that this happens shortly after the rigidbody stops moving for a while.
Edit: I probably should have mentioned that I'm instantiating the volume on top of the rigidbodies.
When should it be displayed? what is this object supposed to collide with? $$anonymous$$aybe you should use OnTriggerStay(), can't say much with so few information provided.
I probably should have mentioned that I'm instantiating the volume on top of the rigidbodies. I had a script that applied force to the rigidbodies, but when using the debug.log statement I noticed they weren't even detected, so there was nothing to apply force to.
$$anonymous$$ake sure the volumes have a collider and are set to trigger?
Answer by Bunny83 · Jul 07, 2015 at 11:31 AM
The physics system is actually quite simple. Only a rigidbody can detect collisions (no matter if we talk about real collisions or triggers). If the rigidbody fell asleep it won't detect anything. As soon as you move a rigidbody it will be woken up. That's why all moving objects should have a rigidbody attached while static geometry doesn't need one since it doesn't move.
If you move a static collider into a sleeping rigidbody it won't detect that. If the collider you move has a kinematic rigidbody it will detect triggers and it can also wake up other rigidbodies.
Real collisions can only be detected by non kinematic RBs. However if the non kinematic RB is sleeping and a kinematic RB is moved into the non kinematic RB, it will be woken up and detect the collision.
As a general rule: If you use physics, never move a collider that doesn't have a rigidbody attached.