i have this code `void Update () {
if(Input.GetMouseButton(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit rayCastHit;
if(Physics.Raycast(ray.origin, ray.direction, out rayCastHit, Mathf.Infinity))
{
clicks+=1;
Debug.Log(clicks);
if (clicks%2!=0) {
Time.timeScale = 0;
BirdMovement.Instance.isPaused = true;
}
if (clicks%2!=1){
Time.timeScale = 1;
BirdMovement.Instance.isPaused = false;
}
}
}
}`
when i make one click on the gameobject , the log shows more clicks ( 4-6 more clicks ) .
i use this c# script to pause and resume the game , but i can't do that successfully if the clicks are more than the real ones .
any suggestion ?
↧