Collider and rigidbody
For a basic gameplay, I wanted to destroy the asteroid when the laser beam hits it. Meaning, the collision between asteroid and laser bullet destroys asteroid. At the same time, laser bullet that collided should also be destroyed.
In Unity, OnTriggerEnter method is called when two GameObjects collide. During this event:
Both the game objects should have Collider component, and
One of the game Objects must have Collider.isTarget enabled, and contain a Rigidbody
COLLIDER
To add a collider in asteroids, the prefabs were opened and Box Collider were added.
Box Collider were sized such that the asteroid is covered in all sides
Box Collider
In laser beams, a capsule collider was added.
Capsule Collider
RIGIDBODY
Rigidbody adds a physics simulation in an object.
In our game "Use Gravity" should not be checked. This will make the object fall in y-direction due to gravity.
Rigidbody Component