- Home /
OnTrigger's Moving Behaviour with Other Triggers
My app moves objects around with a mouse (by manually setting its position without physics), and it needs to detect if the one we're moving is colliding with any of the others. Each has a kinetic rigidbody with discrete collision detection, a script checking its OnTriggerEnter/Exit, and several colliders marked as triggers on child objects.
If I instantiate an object I can move it into a second one and have it detect that second one, no problem. However if I then start moving the second one (which had just been sitting still), it won't detect the first, except in some unexplained cases when I have at least 3 colliders from both coinciding. Oddly if I then move the other one and then come back and move the first one, it'll detect it again. Sometimes the motionless one detects the moving one, but not vice versa when I need the logic to apply to the moving one.
I can reproduce this consistently but I find no rational pattern in it. I know that the physics engine will disable some checking of an object once it's been sitting motionless for a while, but in this case it works for one (identical) object and not another only sometimes after moving the other one and coming back. I suppose I can hack it to work by having all of the OnTriggerEnters of other objects find the one I'm moving and apply the logic to it, but I'd rather find out exactly what is going on for all of our future betterment.