O'Reilly logo

Unity 2D Game Development Cookbook by Claudio Scolastici

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Collision management

While describing the differences between Character Controller and Rigidbody, we have mentioned several times that both these components provide collision detection for the game objects they are attached to. Since collision detection is a fundamental task that must be performed by any game (at least, any game we can think of!) and it can be a hard dude to deal with, in the following recipe, we provide a few examples to show you how collisions actually work in Unity.

If you want to detect whether a collision happens between two game objects, you need both of them to be equipped with a Collider. A Collider is a sort of cage that contains the game object to check whether another game object enters its boundaries. When this happens, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required