Physics messages#

Physics messages are sent between Physics or Physics2D bodies when their colliders interact.

Test whether messages are sent to your objects#

Test that you receive a physics message by using a breakpoint or log.


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

I am not receiving a message#

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).

I am receiving a message twice#

Both objects involved in a collision receive events. If you only want one to run, compare the instance IDs of the objects involved in the collision using GetInstanceID:

// Exit early if this instance ID is less than the other object involved in the collision. 
if (GetInstanceId() < collider.GetInstanceID())