void LateUpdate() { resetPool(); if (!GameManager.instance.IsMenuOpen) { // POSITION OBJECTIVE ARROWS AND INDICATORS Vector3[] waypoints = GameManager.questManager.GetActiveQuestObjectiveTargets(); if (waypoints != null) { foreach (Vector3 waypoint in waypoints) { Vector3 targetPosition = Camera.main.WorldToScreenPoint(waypoint); // If the target is onscreen show the onscreen indicator if (targetPosition.z > 0f && targetPosition.x >= 0f && targetPosition.x <= Screen.width && targetPosition.y >= 0f && targetPosition.y <= Screen.height) { if (targetPosition.z > 500f) { ObjectiveIndicator indicatorImage = getObjectiveIcon(); indicatorImage.GetComponent <RectTransform>().anchoredPosition = new Vector3(targetPosition.x, targetPosition.y, 0f); indicatorImage.SetDistance(Vector3.Distance(waypoint, GameManager.playerTransform.position)); } } else { PositionArrowIndicator(targetPosition, ArrowType.waypoint); } } } // POSITION ENEMY ARROWS AND BOXES var enemies = GameManager.instance.TargetableObjects.Where(t => t.Allegiance == Enums.Allegiance.Enemy); foreach (TargetableObject obj in enemies) { if (GameManager.playerTransform != null) { if (Vector3.Distance(obj.transform.position, GameManager.playerTransform.position) < 500f) { Vector3 targetPosition = Camera.main.WorldToScreenPoint(obj.transform.position); // If the target is onscreen show the onscreen indicator & health bar if (targetPosition.z > 0f && targetPosition.x >= 0f && targetPosition.x <= Screen.width && targetPosition.y >= 0f && targetPosition.y <= Screen.height) { TargetIndicator box = getBoxIndicator(); box.anchoredPosition = new Vector3(targetPosition.x, targetPosition.y, 0f); box.healthBarFillAmount = (float)obj.GetComponent <HealthController>().Health / (float)obj.GetComponent <HealthController>().MaxHealth; float multiplier = (maxAlpha - minAlpha) / alphaThreshold; float currentAlpha = maxAlpha; box.healthBarVisible = false; if (targetPosition.z < alphaThreshold) { box.healthBarVisible = true; currentAlpha = minAlpha + (targetPosition.z * multiplier); } box.boxAlpha = currentAlpha / 255f; //Vector3 lead = CalculateLead(player.transform.position, obj.transform.position, projectileSpeed * 1.5f, obj.gameObject.GetComponent<Rigidbody>().velocity, player.GetComponent<Rigidbody>().velocity); //box.trajectory.rectTransform.anchoredPosition = Camera.main.WorldToScreenPoint(lead) - screenCenter; } else // Offscreen - show directional arrow { if (waypoints == null || !OverlapsWaypoint(waypoints, obj.transform.position)) { PositionArrowIndicator(targetPosition, ArrowType.enemy); } } } } } // Warp target indicators _warpIndicatorInstance.gameObject.SetActive(false); if (GameManager.instance.IsCursorVisible) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; int layerMask = 1 << 2; layerMask = ~layerMask; if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) { WarpTarget target = hit.collider.gameObject.GetComponent <WarpTarget>(); if (target != null) { _warpIndicatorInstance.gameObject.SetActive(true); _warpIndicatorInstance.SetDestinationName(target.TargetName); // Works with sphere colliders Vector3 centerPosition = Camera.main.WorldToScreenPoint(target.Bounds.center); float diffPosition = Camera.main.WorldToScreenPoint(target.Bounds.max).y - centerPosition.y; Vector3 topPosition = centerPosition + new Vector3(0f, diffPosition * 0.8f, 0f); _warpIndicatorInstance.SetNamePosition(topPosition); // Disable entry point indicator if it is currently overlapping an objective marker if (waypoints == null || !OverlapsWaypoint(waypoints, target.Position)) { _warpIndicatorInstance.SetEntryPointPosition(target.Position); } else { _warpIndicatorInstance.DisableEntryPoint(); } } } } } cleanPool(); }