So I noticed that OnCollisionStay() only gets called a fixed number of times and then stops getting called once the sphere stops moving (I assume when physics calculations stop), whereas OnTriggerStay() will keep updating even after the sphere stops moving.
Is this just to optimize physics calculations of the former?
I think part of it is physics optmization, but it's designed that way. OnTriggerStay should be called anytime one object is detected within a trigger and it stays in that trigger. So for example if a character is inside a trigger that could heal them then we could use that to determine if the player is still within the trigger to continue healing them.
OnCollisionStay only gets called when an "active" rigidbody object is detected. I believe once the sphere stops moving it puts the rigidbody to sleep. I'm not sure if this is an oversight on Unity's part but they've recommended that you need to "wake up" a rigidbody for this to continually work. Something like this:
if (rigidbody.IsSleeping()) {
rigidbody.WakeUp();
}
So that's one way to get around that issue. Knowing that you'll have to get creative with using OnCollisionStay to ensure it works as you want.
OK, thanks for the insight. Seems like WakeUp() has to be constantly called in an Update() function to keep it awake.