Created
March 9, 2015 00:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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