public IEnumerator StabilizeY() { EasyTouch.SetEnabled(false); FindNearestAngleY(); while (true) { var condition = MathAngle.FirstAngleBiggerThenSecond(CurrentAngleY, rightAngleY - 1) && MathAngle.FirstAngleBiggerThenSecond(rightAngleY + 1, CurrentAngleY); if (condition) { layerTransform.eulerAngles = new Vector3(CurrentAngleX, rightAngleY, CurrentAngleZ); rotateController.ReshuffleAfterYRotation(prevY, rightAngleY, AngleBetweenPlatforms); prevY = rightAngleY; EasyTouch.SetEnabled(true); yield break; } var angle = GetAngleForYRotation(); layerTransform.Rotate(0, angle, 0); yield return(new WaitForFixedUpdate()); } }
private float GetAngleForYRotation() { var res = speedYRotation; if (MathAngle.FirstAngleBiggerThenSecond(CurrentAngleY, rightAngleY)) { res *= -1; } if (layer.isRotated) { res *= -1; } return(res); }