void Update() { float t = Time.time - scanStart; if (t >= scanFrequency) { t = 0f; scanStart = Time.time; if (scanVisible) { scan.renderer.material.SetFloat("_Start", scanStart); } Collider[] hits = Physics.OverlapSphere(scanOrigin.position, scanRange, scanLayers); for (int i = 0; i < blipMaxCount; ++i) { FpsHudRadarBlip blip = blipContainer.transform.GetChild(i).GetComponent <FpsHudRadarBlip>(); blip.renderer.enabled = false; if (i < hits.Length) { blip.ScanVisible = hits[i].GetComponent <FpsHudRadarVisible>(); if (blip.ScanVisible) { blip.ScanPosition = blip.ScanVisible.transform.position; blip.renderer.enabled = true; } } } } if (scanVisible) { scan.renderer.enabled = t <= scanDuration; for (int i = 0; i < blipMaxCount; ++i) { FpsHudRadarBlip blip = blipContainer.transform.GetChild(i).GetComponent <FpsHudRadarBlip>(); if (blip.ScanVisible) { Vector3 v = blip.ScanPosition - scanOrigin.transform.position; float a = FpsHudUtils.SignedAngle(scanOrigin.transform.forward, v.normalized, Vector3.up); blip.transform.localPosition = new Vector3(0, v.magnitude / scanRange, 0); blip.transform.localRotation = Quaternion.identity; blip.transform.RotateAround(blip.transform.parent.position, blip.transform.parent.forward, -a); } } } blipMaterial.SetMatrix("_MaskMatrix", blipContainer.transform.worldToLocalMatrix); }
void LateUpdate() { FpsHud hud = FpsHud.Instance; Vector3 v = ((TrackTransform.position + TrackOffset) - hud.ActiveCamera.transform.position).normalized; float xAngle = FpsHudUtils.SignedAngle(hud.ActiveCamera.transform.forward, v, Vector3.up); float yAngle = FpsHudUtils.SignedAngle(hud.ActiveCamera.transform.forward, v, Vector3.right); float hFov = hud.ActiveCamera.fov; float vFov = hFov * hud.ActiveCamera.aspect; float hFov2 = hFov / 2; float vFov2 = vFov / 2; if (xAngle < -vFov2 || xAngle > vFov2 || yAngle < -hFov2 || xAngle > hFov2) { if (ClampToSides) { if (xAngle < -90 || xAngle > 90) { // Calculate the flipped inverse angle xAngle = -FpsHudUtils.SignedAngle(-hud.ActiveCamera.transform.forward, v, Vector3.up); // Recalculate yAngle Vector3 yForward = Quaternion.Euler(hud.ActiveCamera.transform.rotation.eulerAngles.x, 0, 0) * Vector3.forward; // Y-only angle yAngle = FpsHudUtils.SignedAngle(yForward, v, Vector3.right); yAngle = yAngle < 0 ? -vFov2 : vFov2; } xAngle = Mathf.Clamp(xAngle, -vFov2, vFov2); yAngle = Mathf.Clamp(yAngle, -vFov2, vFov2); } else { renderer.enabled = false; return; } } float xRatio = (xAngle + vFov2) / vFov; float yRatio = 1 - ((yAngle + hFov2) / hFov); float xMin = -Screen.width / 2; float yMin = -Screen.height / 2; float xPosition = xMin + Screen.width * xRatio; float yPosition = yMin + Screen.height * yRatio; renderer.enabled = true; transform.position = new Vector3(xPosition, yPosition, 1).ToScreenPosition(); }
void Update() { if (!target) { target = FpsHud.Instance.PlayerCamera.transform; } Vector3 f = target.forward; f.y = 0; float a = Mathf.Repeat(360f + FpsHudUtils.SignedAngle(north, f.normalized, Vector3.up), 360f) / 360f; renderer.material.mainTextureOffset = new Vector2(textureOffset + a, 0); }
void Update() { Spread = Mathf.Clamp01(Spread); if (Spread != previousSpread) { int pixelSpread = Mathf.Clamp(Mathf.RoundToInt(Spread * MaxSpred), MinSpred, MaxSpred); TopLeft.position = FpsHudUtils.ToScreenPosition(topLeftOffset + (topLeftVector * pixelSpread)); TopRight.position = FpsHudUtils.ToScreenPosition(topRightOffset + (topRightVector * pixelSpread)); BottomLeft.position = FpsHudUtils.ToScreenPosition(bottomLeftOffset + (bottomLeftVector * pixelSpread)); BottomRight.position = FpsHudUtils.ToScreenPosition(bottomRightOffset + (bottomRightVector * pixelSpread)); previousSpread = Spread; } }
void Update() { Spread = Mathf.Clamp01(Spread); if (Spread != previousSpread) { int pixelSpread = Mathf.Clamp(Mathf.RoundToInt(Spread * MaxSpred), MinSpred, MaxSpred); Left.position = FpsHudUtils.ToScreenPosition(new Vector3(-PixelHeight - pixelSpread, (PixelWidth / 2), 1)); Right.position = FpsHudUtils.ToScreenPosition(new Vector3(pixelSpread, (PixelWidth / 2), 1)); Top.position = FpsHudUtils.ToScreenPosition(new Vector3(-(PixelWidth / 2), PixelHeight + pixelSpread, 1)); Bottom.position = FpsHudUtils.ToScreenPosition(new Vector3(-(PixelWidth / 2), -pixelSpread, 1)); previousSpread = Spread; } }
public void Display(Vector3 source) { if (target) { Vector3 forward = target.forward; // Ignore y rotation source.y = 0; forward.y = 0; source.Normalize(); forward.Normalize(); Vector3 direction = (source - target.position).normalized; float angle = FpsHudUtils.SignedAngle(target.forward, direction, Vector3.up); // Intfront of us if (angle >= -45f && angle <= 45f) { Display(FpsHudSplatterSide.Top); } // Left side else if (angle <= -45f && angle >= -135f) { Display(FpsHudSplatterSide.Left); } // Right side else if (angle >= 45f && angle <= 135f) { Display(FpsHudSplatterSide.Right); } // Behind else { Display(FpsHudSplatterSide.Bottom); } } }