Shadow Caster Doubles

Sometimes, you may want to have one object cast shadows to represent another object.

For example, in the Mech Combat Kit, the first person view is not anchored to the mech model, because the mech model's walking animations cause far too strong and disorienting movement of the camera. Instead, in first person view, the cockpit (and weapons) are separated from the rest of the mech, where their own animations can be adjusted until the player experience is comfortable. Yet the player still must be able to see their shadows moving around as if the weapons are part of the swaggering mech model.

To do this, Shadow Caster Doubles are used for the weapons, which are invisible meshes that are attached to the mech model and cast shadows for the actual weapons that have been removed.

Creating a Shadow Caster Double

To create a shadow caster double for a weapon module (or any other module) add a Shadow Caster Double component to the weapon module's root transform.

You will need to add other mesh(es) to your module, go to their Mesh Renderer components, and in the inspector set Lighting > Cast Shadows to Shadows Only. This means the mesh is invisible but will cast shadows.

Next, drag a single gameobject that contains all the invisible meshes in its hierarchy into the Shadow Caster Double component's Shadow Caster Objects list.

Then go to the visible meshes of your module, go to the Mesh Renderer component's inspector, and set Cast Shadows to Off. This means the mesh is visible but won't cast any shadows.

Setting Up The Shadow Caster Double

Go to all the module mounts on your vehicle where a shadow caster double module may be mounted, and add a Module Mount Shadow Caster Anchor component. In the inspector, you can specify where the shadow caster double object should be placed. For a mech, this would be somewhere on the skeleton of the mech.

Last updated