Hey guys,
I have a script set up on an object will tells it to replace itself with another object after 3 seconds. this works fine, but what I want to do with it is to attach the code to it that will allow it to die by being triggered by colliding with another object. Here’s the existing script:
#pragma strict
var Jack : GameObject;
yield WaitForSeconds(3);
KillSelf();
}
function KillSelf () {
var JackBreak = Instantiate(Jack, transform.position, transform.rotation);
Destroy(gameObject);
}
I know it’s an OnTriggerEnter event like this, but don’t know where to put it:
void OnTriggerEnter(Collider other) {
if (other.tag == "DestroyObject")
{}
My assumption is it goes at the top after the var: but can’t seem to get it to work.
Any help would be appreciated.
Rich