Make Objects to ricochet

I was wondering if there is a way for objects to ricochet in the scene. I want to have some objects to move around as they collide with the wall and to keep on moving. Is there any source code to help have objects to ricochet?

Look at these 2 answers:

In the deflecting bullet, there is a short explanation on how one could calculate the ricochet angle/vector of a bullet. In the billiard game guide line, there is a example script regarding reflecting/bouncing the vector.

What you will do with a projectile/bullet are:

  1. Check with colliding with a ricochet-able surface ( OnCollisionEnter )
  2. Extract the normal of the surface you are colliding via contact point
  3. Use the projectile/bullet’s direction ( transform.forward ) and the normal to calculate the vector of the projectile/bullet when it is reflected Vector3.Reflect
  4. Apply the reflected vector to your projectile/bullet