- Home /
This question was
closed Dec 10, 2014 at 10:12 AM by
HarshadK for the following reason:
Duplicate Question
Question by
JupiterMaroo · Dec 10, 2014 at 10:10 AM ·
crashmonodevelop
Unity crashes when executing a script onMouseDown
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.
Comment
This type of question is already answered many times before on UA.
The reason is because of your while loop which goes into infinity since you are trying to compare two floats.
You should compare two floats for equality using $$anonymous$$athf.Approximately.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Chartboost Ad not showing in Device 1 Answer
MonoDevelope is not opening! 1 Answer
Monodevelop Won't Run 1 Answer
A node in a childnode? 1 Answer