Behind the scenes

The script creates a child game object with a Camera and Projector components. It also creates a RenderTexture for the shadow and sets everything up.

Then each frame it tracks the "character" object and modifies camera/projector so that their view fully encloses the object. It always uses orthogonal projection for the shadow because it was easier to implement :) and that's what you want most often anyway.

The rendering happens by rendering only the character object, with setting pixel light count to zero before and restoring it afterwards. Then a fullscreen quad is drawn on the shadow rendertexture to actually get the uniform dark color for the shadow (this is done by using a ZTest Greater in the shader).

History

2008 Feb 20 Shadow casting object can be a hierarchy of objects (all have to use same layer though)

2008 Feb 14 Fix issues with multiple character shadows in the scene and with overlapping shadows