- Home /
Question by
RichCoggin · Apr 17, 2013 at 09:54 AM ·
collisioninstantiatetrigger
trigger replace prefab with another...
Hi there,
I have the following script which replaces a prefab with another prefab on collision. This is fine. What I want to do is create a script where the 'Destroy' object is a trigger object (has trigger clicked) and the object colliding with it is again replaced with another prefab and stays on the scene. Here's the script without trigger. Also, would this be placed on the object or the trigger object?
#pragma strict
var Jack : GameObject;
function KillSelf () {
var JackBreak = Instantiate(Jack, transform.position, transform.rotation);
Destroy(gameObject);
}
function OnCollisionEnter(collision : Collision) {
if (collision.gameObject.tag == "Destroy")
KillSelf();
}
Thanks in advance for your help.
R
Comment