protected override Vector3 CalculateStartPosition(ref Vector3 anchorPosition, Camera visibleInCamera, bool intense) { Vector3 start = anchorPosition; Vector3 randomDir; if (visibleInCamera == null) { randomDir = UnityEngine.Random.onUnitSphere; } else { Vector3 randomScreenPoint = new Vector3 ( UnityEngine.Random.Range((float)visibleInCamera.pixelWidth * 0.3f, (float)visibleInCamera.pixelWidth * 0.7f), UnityEngine.Random.Range((float)visibleInCamera.pixelHeight * 0.3f, (float)visibleInCamera.pixelHeight * 0.7f), Random.Range(visibleInCamera.nearClipPlane, visibleInCamera.farClipPlane) ); randomDir = (visibleInCamera.ScreenToWorldPoint(randomScreenPoint) - visibleInCamera.transform.position).normalized; } start += (randomDir * (intense ? IntenseDistance.Random() : NormalDistance.Random())); start.x += StartXVariance.Random(); start.y = StartYVariance.Random() + StartYBase.Random(); start.z += StartZVariance.Random(); // if the start is too close to the anchor point, push it back float minDistance = (intense ? IntenseDistance.Minimum : NormalDistance.Minimum); if (Vector3.Distance(start, anchorPosition) < minDistance) { Vector3 startDir = (start - anchorPosition).normalized; start = anchorPosition + (startDir * minDistance); } return(start); }
protected override Vector3 CalculateStartPosition(ref Vector3 anchorPosition, Camera visibleInCamera, bool intense) { Vector3 start = anchorPosition; Vector3 randomDir; if (visibleInCamera == null) { randomDir = UnityEngine.Random.onUnitSphere; } else { Vector3 randomScreenPoint = new Vector3 ( UnityEngine.Random.Range((float)Screen.width * 0.2f, (float)Screen.width * 0.8f), UnityEngine.Random.Range((float)Screen.height * 0.2f, (float)Screen.height * 0.8f), visibleInCamera.farClipPlane * 0.5f ); randomDir = visibleInCamera.ScreenToWorldPoint(randomScreenPoint).normalized; } randomDir.y = Mathf.Abs(randomDir.y); randomDir *= (intense ? IntenseDistance.Random() : NormalDistance.Random()); randomDir.y = StartYBase.Random(); start += randomDir; start.x += StartXVariance.Random(); start.y += StartYVariance.Random(); start.z += StartZVariance.Random(); // if the start is too close to the anchor point, push it back float minDistance = (intense ? IntenseDistance.Minimum : NormalDistance.Minimum); if (Vector3.Distance(start, anchorPosition) < minDistance) { Vector3 startDir = (start - anchorPosition).normalized; start = anchorPosition + (startDir * minDistance); } return(start); }