- Home /
Question by
Grievemourne · Jun 26, 2015 at 02:10 AM ·
collisionrigidbodyforcesleepaddexplosionforce
What does rigidbodies sleeping have to do with collision detection?
I have a script that fails to interact with rigidbodies inside its trigger collider once those rigidbodies have stopped moving and fallen asleep.
public class ForceBack : MonoBehaviour {
public float radius = 100.0F;
public float power = 100.0F;
void OnTriggerEnter(Collider col){
Vector3 explosionPos = GetComponentInParent<Transform>().transform.position - GetComponentInParent<Transform>().transform.forward * 3;
Rigidbody rb = col.GetComponent<Rigidbody>();
Debug.Log (col.name + " is in the volume");
if (rb != null){
rb.AddExplosionForce(power, explosionPos, radius, 2.0F);
Debug.Log (rb.name + " has had explosive force applied to it");
}
}
}
They are no longer detected by the OnTriggerEnter function once this happens. It feels like a catch 22 when I'm trying to apply force to a rigidbody, but can't do it while it's asleep, and have to apply force to wake. I'd prefer not to wake them up by applying other forces in different ways, so I'm hoping to hear differently.
Comment