Build your own GameObject Caster

2DDL Documentation

Let’s see how convert an existing gameObject into a shadow caster.

I’ll use a cube for this example.

Start by doing the following:

  1. Create a 3d Cube GameObject (GameObject → Create other → Cube)

  2. Delete any collider that the GameObject has, in this case we’ll remove the BoxCollider.

  3. Create an empty GameObject and make it a child of the Cube GameObject you created in step 1.

  4. Add a PolygonCollider2D component to the child GameObject

  5. Make sure you adjust the PolygonCollider2D to match the Cube if it doesn’t do it already.

Important Note:

Make you sure to set the Z position to the same GameObject Z position. Why? Because it needs to be aligned between the Light and the Collider so the raycasting actually hits it.

Check that the Layer in the 2DLight gameObject is in the desired Layer  e.g my desired layer is “ShadowLayer” (Default = ShadowLayer)

setCaster

The GameObject is ready to work with 2DDL.