function Update() {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.forward, hit, 2)) {
if(hit.collider.gameObject.tag == "Player" && /* The button action is activated */) {
if (door == true) { // Opend the doors
countA += 0.01;
}
}
}
if (countA == 1) { // The doors are totally open
door = false;
}
if (countA > 0 && door == false) { // Close the doors
countA -= 0.01;
}
door_Left.localPosition = Vector3(-countA, 0, 0);
door_Right.localPosition = Vector3(countA, 0, 0);
}
This should work, when work with two objects (one in front another) just type value and -value to set positive and negative motion, the recommendation it's to use always positive number so this can be made negative using the "-" before the value, if you use the boolean state in a "if" statement with the same boolean as a condition this will interrupt if condition and the loop will be interrupted.