So I have a green button, that when I press it, the door goes down and closes. Here is my script that is attached to the button.
using UnityEngine;
using System.Collections;
public class DoorButtonLeft : MonoBehaviour {
public GameObject doorleft;
public float closeSpeed =3f;
void OnMouseDown ()
{
while (doorleft.transform.position.y != 4.322434)
{
doorleft.transform.Translate (Vector3.down * closeSpeed * Time.deltaTime);
}
}
}
All it does is crash my unity. Please help.
↧