DontGoThroughThings

Author: Daniel Brauer, Adrian

Description
This script uses raycasting to avoid the physics engine letting fast-moving objects go through other objects (particularly meshes).

Changes
v1.1 (Boo):
 * Added "Switch To Layer" convenience option to move the game object to a given layer and remove that layer from the layer mask (the original layer is restored if used together with "Time to Live").
 * Added "Time to Live" option to automatically destroy the script after a given time to reduce raycasts and instances.
 * Moved initialization to an Init method to make the script more usable if added through script.

Usage
Attach the script to any object that might move fast enough to go through other colliders. Make sure that the LayerMask does not include the layer of the object the script is attached to, otherwise the object will collide with itself. Leave Skin Width at 0.1 unless the object still passes through other colliders. If this happens, increase the skin width until the issue stops or you reach a value of 1.0.

Boo - DontGoThroughThings.boo
(See Script Compilation as for how Boo scripts can be used from JavaScript and C#).