Issue with trigger enter/exit detecting collisions

As RadRed says, use the Overlap family of calls.

The main reason: OnTrigger* / OnCollide* will NEVER be called while you do stuff in your script. They are called at a very specific part of the main game loop, during the physics cycle, as you can see here:

ALSO, with Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

1 Like