bounce script for objects in unity code example
Example: bounce script unity
void OnCollisionEnter(Collision collisionInfo){
rigidbody.AddForce(Vector3.Reflect(direction, collisionInfo.contacts[0].normal) * mag, ForceMode.Impulse);
}
void OnCollisionEnter(Collision collisionInfo){
rigidbody.AddForce(Vector3.Reflect(direction, collisionInfo.contacts[0].normal) * mag, ForceMode.Impulse);
}