- Home /
OnCollisionStay stops firing after a second or two?
I just have a simple test scene with a Rigidbody box on a BoxCollider floor. Not even a mesh. But the OnCollisionStay message seems to only fire for a second or two and then it stops. What's the deal here?
Answer by Waz · Aug 30, 2011 at 04:06 AM
Thanks. Speed won't be an issue for me, so I just wake it up every frame if it is asleep.
Then you can just set the rigidbody.sleepVellocity and sleepAngularVelocity to 0, rather than waking it up.
Answer by Rafes · Aug 30, 2011 at 04:00 AM
If your rigid body stops moving it falls asleep. Try adding this script to the GameObject with the RigidBody to test if this is your issue:
using UnityEngine;
using System.Collections;
/// <summary>
/// A simple script to keep a Rigidbody alive. This simply adds an
/// extremely small value to this transform's local X rotation.
///
/// Use this for testing triggers with stationary colliders
/// </summary>
public class StayAwake : MonoBehaviour
{
/// <summary>
/// Runs on frame update
/// </summary>
private void Update()
{
transform.Rotate(Time.time * 0.00000001f, 0, 0);
}
}
The question was why the test was failing, I just posted a method to debug. I wrote this a few days in to learning Unity and never looked back. This script could be updated. See warwick's comment.