Skip to content

Instantly share code, notes, and snippets.

@OutlawGameTools
Created March 9, 2015 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OutlawGameTools/21b0bf7168497de1d2ed to your computer and use it in GitHub Desktop.
Save OutlawGameTools/21b0bf7168497de1d2ed to your computer and use it in GitHub Desktop.
CS109 - Attach to an explosion, it deletes it after done. Optionally kills Enemies caught inside blast radius.
#pragma strict
public var liveTime : float = 0.5f; // how long to wait before ditching the explosion
public var killWithTag : String = "Enemy"; // kills these tagged objects in the blast radius
function Start ()
{
Invoke("DeleteMe", liveTime);
}
function DeleteMe ()
{
Destroy(gameObject);
}
function OnTriggerEnter2D(other : Collider2D)
{
// if explosion has a trigger collider, also kill
// Enemy objects in the blast radius
if (other.gameObject.CompareTag(killWithTag))
{
Destroy(other.gameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment