Hello
this code does so when I press the A key or the B key, the elevator stops upwards on the first or second floor. The question is how do I modify the code that when the elevator is on the second floor, for example, and I press the A key again to make the elevator go down to the first floor? Question two If I replace if (Input.GetKey (KeyCode.A)) {} with this if (Input.GetKeyUp (KeyCode.Keypad1)) {} so the code does not work. Why? Thank you for advice Sorry for the bad English. Here is the code
public GameObject lift;
private bool keyHHit=false;
private bool keyHHitB=false;
void Update () {
if (Input.GetKey(KeyCode.B)) {
keyHHit=true;
}
if( keyHHit==true){
if(transform.localPosition.y >= 14.52){
transform.Translate(new Vector3(0, 0, 0) * 2 * Time.deltaTime, Space.Self);
}else{
transform.Translate(new Vector3(0, 2, 0) * 2 * Time.deltaTime, Space.Self);
}
}
if (Input.GetKey(KeyCode.A)) {
keyHHitB=true;
}
if( keyHHitB==true){
if(transform.localPosition.y >= 8.52){
transform.Translate(new Vector3(0, 0, 0) * 2 * Time.deltaTime, Space.Self);
}else{
transform.Translate(new Vector3(0, 2, 0) * 2 * Time.deltaTime, Space.Self);
//transform.Translate(Vector3.up * 0.05f);
}
}
}