hello,
in the following code what i’m trying to do is when you press a key, and a certain object is colliding with the trigger, that object becomes child of the trigger. When you press that key again, the child is released. It appears to work fine, but it sometimes responds as it should and sometimes you press the key and nothing happens, and when the object is on the edge of the trigger it won’t be released anyomre.
function Update () {
}
function OnTriggerStay(other : Collider) {
if (Input.GetButtonDown("pegar") other.CompareTag("farol")){
if(other.transform.parent != this.transform) {
other.transform.parent = this.transform;
} else {
other.transform.parent = null;
}
}
}
}