Hi, you’ll see, i have this code, i need to destroy a hinge joint component of a door from the script of a trigger, but when i run the code, it erases the entire door, what am doing wrong or what can i do? i don’t want to have a script per door because there are so many of them :I
#pragma strict
var levelStuff : GameObject;
var activar : boolean;
var mustKill : boolean = false;
var doorToKill : GameObject;
var killLevel : GameObject;
var createSomething : boolean = false;
var somethingToCreate : GameObject;
function Start () {
}
function Update () {
}
function OnTriggerEnter(col : Collider)
{
if(col.gameObject.tag == "personaje")
{
if (activar == false)
{
levelStuff.SetActive (false);
Debug.Log("borrado");
}
if (activar == true)
{
levelStuff.SetActive (true);
Debug.Log("dibujado");
}
if (mustKill == true)
{
Debug.Log("puerta cerrada");
Destroy(doorToKill.GetComponent(HingeJoint)); //<- this is the problem, i think :I
Destroy(killLevel);
}
if (createSomething == true)
{
somethingToCreate.SetActive(true);
}
}
}
Thnks :b