Visibility ** Line of Sight ** Cover explosion and shockwave bomb

2DDL Documentation

One of powerful feature of 2DDL package is a “Visibility and cover explosion” algorithm. This approach is excellent for type games like Bomberman, Mining and others alike. The 2DDL package comes ready to work for this feature but need a minimum set-up for it.

1) Create a new empty scene and add a 2dLight

2) Select 2DLight and find in the inspector window the variable “Use Events” and set it to true.


3) Create a new C# script, call it “ReachedEventManager.cs” and put the following code in it:

using UnityEngine;
using System.Collections;


public class ReachedEventManager : MonoBehaviour {

	DynamicLight light2d;
	GameObject[] GOsReached;
	TextMesh text;

	void Start () {
		// Find and set 2DLight Object //
		light2d = GameObject.Find("2DLight").GetComponent() as DynamicLight;

		// Find and set text obj //
		text = GameObject.Find("text").GetComponent();

		// Add listener
		light2d.InsideFieldOfViewEvent += waveReach;


	void waveReach(GameObject[] g){
		//- this function iterate in each object passed by 2DLigh script and compare if this object
		// is EQUAL TO player game object --//

		bool found = false;
		string gsName = "";

		foreach(GameObject gs in g){
			if(gameObject.GetInstanceID() == gs.GetInstanceID()){
				found = true;
				gsName =;
		if(found == true){
			text.text = "PLAYER REACHED!!  _" + gsName +"__" + Time.time;
			text.text = "in safe place";



4) Create a new “Player” gameObject and drop in the ReachedEventManager.cs script inside.

5) Create a new TextMesh, call it “Text”. Do this to show the message in the scene.

6) Add any time of Casters like squares, hexagons to give some cover area. Run the project, move the light between obstacles and then you will notice the obstacles are covering the light.

Important Note: The Caster need a 2D Polygon Collider as a child,  otherwise , you will receive an error.

DOWNLOAD EventReachedManager.cs

The Animation below shows the example scene included in the 2DDL package named “3.Visibility and CoverExplosion(shockwave)”