2y ago · Nov 14, 2023 11:20 AM
Displaying distance in meters below enemy bounding boxes helps players gauge threat priority and weapon damage falloff ranges.
Distance Calculation & Text Label Formatting:
Distance Calculation & Text Label Formatting:
CSHARP
using UnityEngine;
public static class DistanceESP
{
public static void DrawDistance(Vector3 localPlayerPos, Vector3 targetPos, float boxX, float boxY, float boxWidth, float boxHeight)
{
// Calculate Euclidean distance in 3D world space
float distance = Vector3.Distance(localPlayerPos, targetPos);
string text = $"[{Mathf.RoundToInt(distance)}m]";
GUIContent content = new GUIContent(text);
GUIStyle distStyle = new GUIStyle(GUI.skin.label)
{
alignment = TextAnchor.MiddleCenter,
fontSize = 10,
fontStyle = FontStyle.Normal
};
distStyle.normal.textColor = new Color(0.85f, 0.85f, 0.85f, 0.9f);
Vector2 size = distStyle.CalcSize(content);
float posX = boxX + (boxWidth * 0.5f) - (size.x * 0.5f);
float posY = boxY + boxHeight + 2f;
// Shadow + Label
GUI.color = Color.black;
GUI.Label(new Rect(posX + 1, posY + 1, size.x, size.y), content, distStyle);
GUI.color = Color.white;
GUI.Label(new Rect(posX, posY, size.x, size.y), content, distStyle);
}
}
AimbotMath · Angular Normalization & Smooth Angles
The following users thanked AimbotMath for this post: