- Home /
OnTriggerEnter only sent to one of the colliding objects, not both?
So I have a player, with a SphereCollider trigger and a Rigidbody. I also have a pants-load of bullets, each with a SphereCollider trigger and a Rigidbody. The player is the first thing spawned into the scene (which may be important in a minute).
When I start playback, the player can collide with every bullet in the way you'd expect. After the player dies and respawns once -- which means that GameObject was disabled via SetActiveRecursively, then re-enabled in the same fashion three seconds later -- his collision with bullets becomes inconsistent, in a very peculiar way: some bullets, seemingly at random, are now completely un-collidable no matter what, while the rest of the bullets continue to collide normally.
The script logic that's telling me a collision has occurred is located in the Player's OnTriggerEnter. In a fit of desperate flailing, I tried duplicating that logic into the bullet's OnTriggerEnter... and this fixed the issue entirely. O_O
So what it looks like, is that for some as-yet-unknown reason, I'm getting into a state where some bullet->player collisions are only calling OnTriggerEnter on the bullet, and not on the player, while other bullet->player collisions are calling OnTriggerEnter on both objects.
Uh... WTF? Isn't this, like, impossible? O_o
SetActiveRecursively has been deprecated since 4.0 (November 2012). SetActive does what SetActiveRecursively used to do, and the recursive version isn't documented anymore. So you should probably change that at least. It might be causing some wonk.
Otherwise I've got no idea.
Your answer
Follow this Question
Related Questions
Is there anyway to make an object impenetrable? 1 Answer
OnTriggerEnter detection too late 0 Answers
Weird OnTriggerEnter / Exit behavior 1 Answer
My trigger is called twice 1 Answer
Check collision of childs Trigger in Parents script [JS] 1 Answer