hy guys,i’ve a little problem and it make me crazy.
I’m trying to attach other object(caravan) to my car,and i want it is attachable onli if the car is in correct position.
I’ve addend in car and in caravan 2 empty mesh,and that’s are setting “isTrigger”,because only when this 2 trigger have a collision i want is able to attach.
now i’ve made this script:
var currentTrigger : Transform;
var currentTriggerName : String;
var attaccato : boolean = false;
var atx : boolean = false;
private var other: Object;
function Update() {
if (Input.GetKey(KeyCode.C)) {
Debug.Log("attacca premuto");
if (atx) {
Debug.Log("aggancio");
transform.parent = other;
attaccato = true;
}
}
if (Input.GetKey(KeyCode.X)) {
Debug.Log("stacca premuto");
if (attaccato) {
Debug.Log("sgancio");
transform.parent = null;
attaccato = false;
}
}
}
function OnTriggerStay(other) {
if (other.isTrigger == true){
Debug.Log("yay0");
if (other.name == currentTriggerName) {
Debug.Log("yay1");
atx = true ;
Debug.Log("atx ready");
}
}
}
in the log i seen the text,but caravan doesen’t attach to my car.in don’t understand where is error,because the log don’t show any error.