I have this code that allows swiping the camera around on a mobile phone
Now I have a button on the screen which can only be selected if the camera is not moving, set up like this:
private Vector3 checkCamPos = Vector3.zero;
public Vector3 newCamPos = Vector3.zero;
void OnMouseDown()
{
checkCamPos = Camera.main.gameObject.transform.position;
}
void OnMouseUp()
{
newCamPos = Camera.main.gameObject.transform.position;
if (checkCamPos == newCamPos && BuildMenuPopUp.gameObject.activeInHierarchy == false)
{
BuildMenuPopUp.gameObject.SetActive (true);
GameObject.Find("Main Camera").GetComponent<ScoresAndVariables>().ActiveMenu = true;
}
It works well, except for the fact that with the swiping script, a little press on the screen makes the camera move 0,03x or 0,03z for instance
Hence when that happens, the button doesn’t work anymore.
Is there any way I can check something like
if (vector3 checkCamPos 'is within 0,03x AND 0,03z' of newCamPos)
{
code;
}