Compound colliders, OnTriggerstay and unity5.1

Hi, I was testing 5.1 and I ran into a problem with my game which was working fine in 5.0. The thing is OnTriggerStay events don’t get fired for compound colliders,

My current setup that used to work but now doesn’t

Cube1 <= no colliders, rigidbody, OnTriggerStay script
Cube2 <= no interesting component
Cube3 <= mesh collider + box collider
Sphere <= sphere collider marked as trigger

This used to work fine, once Cube3 entered the Sphere trigger the OnTriggerStay was called on Cube1, now after upgrading to 5.1 this doesn’t seem to work, OnTriggerEnter and OnTriggerExit get called on Cube1, but not Stay.

Anybody else have this issue or is this me doing something wrong?

Well this is odd, but maybe not. If I attach a script to Cube3 (which should detect OnTriggerStay) and it contains nothing except an empty OnTriggerStay definition (well apart from the usual class definition etc.)

void OnTriggerStay(Collider coll){
}

Thent Cube1 registers a OnTriggerStay event. I don’t know if this is intended behaviour. Well, then this is an easy fix. Just add this empty script to all my collider objects that need to register OnTriggerStay’s for the parent object.

2 Likes

I reported this big yesterday; Unity is aware of it and fixing. Seems like there was an OnTriggerStay optimization in 5.1 that broke compound colliders.

Nice workaround! I was doing a little more effort in our project to work around it for now.

Yeah, I figured it was something that got a bit too optimized :slight_smile:

Thanks for the workaround! Just ran into this issue here too.

Here’s hoping for a quick fix.

Cheers

Big thanks for this workaround sjt!

So, I hear (or actually, read on the release notes) that Unity 5.1.2p1 has this fixed already.

Might not need to do the workaround anymore.

Cheers