public void Update() { windChangeTimer += Time.deltaTime; if (windChangeTimer >= TIME_TO_WIND_CHANGE) { windState = GetNext(windState); windAnimationState = WindAnimationState.TRANSITIONING; windChangeTimer = 0; targetWindSpeed = GetNewSpeed(); windTransitionVariable = (targetWindSpeed - windSpeed) / TIME_FOR_TRANSITION; testTimer = 0; } if (windAnimationState == WindAnimationState.TRANSITIONING) { windSpeed += windTransitionVariable * Time.deltaTime; testTimer += Time.deltaTime; if ((Mathf.Abs(windSpeed) >= Mathf.Abs(targetWindSpeed))) { windSpeed = targetWindSpeed; windAnimationState = WindAnimationState.IDLE; } } }
public WindVelocitySelector() { windState = WindState.CALM; windAnimationState = WindAnimationState.IDLE; windSpeed = GetNewSpeed(); }