private void FixedUpdate() { Debug.Log(ValidHands()); if (TrackHands) { if (!ValidHands()) { HandsShakeTimer = 0; } else { HandsShakeTimer += Time.deltaTime; } } if (HandsShakeTimer > 2) { if (SnowMoundBehavior.canSpawnSnowball) { SnowballBehavior b = Instantiate(vrHands.SnowballPrefab).GetComponent <SnowballBehavior>(); b.SetOVRGrabberFollow(GetOVRGrabber(true)); } else { Snowfall.ActiveSnowball().ScaleUp(LeftHandPositionDerivative + RightHandPositionDerivative); Debug.Log("Add to snowball" + (LeftHandPositionDerivative + RightHandPositionDerivative)); } } }
public static IEnumerator SufficientHandMovement(float threshold, float seconds) { float t = 0; while (ValidHands(threshold) && t < seconds) { t += 1; yield return(new WaitForSeconds(1)); if (t > seconds) { break; } } if (t >= seconds) { if (SnowMoundBehavior.canSpawnSnowball) { SnowballBehavior b = Instantiate(vrHands.SnowballPrefab).GetComponent <SnowballBehavior>(); b.SetOVRGrabberFollow(GetOVRGrabber(true)); Debug.Log("Sufficient Hand Movement, spawn snowball"); } else { Snowfall.ActiveSnowball().ScaleUp(LeftHandPositionDerivative + RightHandPositionDerivative); Debug.Log("Add to snowball" + (LeftHandPositionDerivative + RightHandPositionDerivative)); } } else { yield return(vrHands.StartCoroutine(SufficientHandMovement(threshold, seconds))); } }