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.position - GetComponentInParent().transform.forward * 3;
Rigidbody rb = col.GetComponent();
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.
↧