Layer Collision Matrix

The Layer Collision Matrix allows you to control which GameObjects can collide and interact with others based on the layers to which they are assigned. This means you can have certain objects able to collide only with specific ones if desired. In Figure 7.2 you can see that we are allowing all objects the ability to interact with the exception of the player on himself. This is to avoid any anomalies with the physics of the player.

Note

If the dynamics of your GameObjects are unrealistic or not behaving as expected, you may need to adjust the GameObject’s Rigidbody, or the Gravity or Drag values in the Physics 2D Settings. This is especially true with 2D sprites, as their weight may be affected differently. Also remember ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.