Skip to content

Instantly share code, notes, and snippets.

@OutlawGameTools
Created March 12, 2015 10:35
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/eaead48ff8e02023df70 to your computer and use it in GitHub Desktop.
Save OutlawGameTools/eaead48ff8e02023df70 to your computer and use it in GitHub Desktop.
CS109 - Attached to a ship, kills itself and instantiates an explosion when it hits a trigger2d collider.
#pragma strict
public var expl : GameObject;
function OnTriggerEnter2D (other : Collider2D)
{
var newPos : Vector3 = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, 0);
Instantiate(expl, newPos, Quaternion.identity);
Destroy(gameObject);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment