- Home /
OnTriggerStay still called after moving a parent gameobject
I have a gameobject prefab that contains a basic CharacterController and a sub-gameobject that contains a MeshCollider with a procedural mesh (marked as IsTrigger and Convex). I instantiate two entities from this prefab.
Case with no problem :
the first entity is not moving. When the second entity enters the MeshCollider of the sub-gameobject of the first entity, The first entity receives the trigger OnTriggerEnter, OnTriggerStay when the second entity stay in it, and OnTriggerExit when the second entity leaves the collider. No problem here.
Case with problem :
The second entity enters the collider of the first entity's sub-gameobject. The first entity receives OnTriggerEnter and OnTriggerStay as expected. But when the first entity moves away, and the second entity is not in the collider of the first entity anymore, the first entity still get OnTriggerStay calls. I thought this was a problem with sub-gameobject collider world position but this is getting stranger. If the second entity moves, the first entity gets the OnTriggerExit call. If the second entity moves in the collider at the new position, i get OnTriggerEnter, OnTriggerStay again. The gizmos of the collider is moving according to the parent gameobject so the mesh collider is correctly positionned.
I don't know why OnTriggerStay is called again and again until the second entity moves.
No idea guys? Should I send a bug report or maybe I've done something wrong?
If you need more precisions, please ask.