🤔

Physics queries#

Physics queries include casts, overlaps, and checks in the Physics or Physics2D classes.

Test whether your query hits an object#

Test that a physics query hits an object by using a breakpoint or log.

warning

Don't put breakpoints or logs after or inside other code when testing a method runs.

I am receiving a message but no logic runs#

You likely have an error in your logic. Common mistakes include:

  • Comparing tags using equality; use CompareTag to get proper warnings.
  • Destroying components instead of their gameObject, leading to the appearance that nothing happens.
  • Ignoring errors that throw exceptions, these cause the code after to not run (fix the exceptions to resolve the issue).