FiveM 3D Distance Calculator
Calculate 3D and 2D distances between two sets of coordinates. Get travel time estimates and ready-to-use Lua code.
Point A
Point B
What this tool is for
Distances decide when a marker is drawn, when an interaction becomes possible and when a loop may go to sleep. Getting them wrong is one of the most common causes of a script that eats frames. This calculator gives you the 3D and the 2D distance between two points and writes the comparison in the form that costs the least performance.
How to use it
- Step 1:
Enter both points, for example the player position and the target of an interaction.
- Step 2:
Read off the 3D distance for anything with height difference, and the 2D distance when only the ground plane matters.
- Step 3:
Derive your check radius from it. A marker at 20 metres, the interaction prompt at 2 metres is a common pattern.
- Step 4:
Copy the Lua line. It uses the vector subtraction form, which is faster than Vdist.
Frequently asked questions
Should I use #(a - b) or Vdist?
Use #(a - b). It is native vector arithmetic inside the Lua runtime, while Vdist is a game native and every native call carries overhead. In a loop that runs every frame the difference is measurable.
When is the 2D distance the right one?
Whenever height should not matter, for example a zone that covers all floors of a building, or a marker on a slope. With the 3D distance a player one floor up falls out of the zone, which reads as a bug.
How do I avoid a distance check every frame?
Use a two stage loop. Sleep 1000 ms while far away, and only when the player is inside the outer radius switch to a 0 ms loop for the actual interaction. This alone brings most scripts from several milliseconds down to near zero when idle.
Can I compare squared distances instead?
Yes, and it saves the square root. Compare #(a - b) against a squared threshold only if you square the threshold as well. It is a real optimisation only in loops over many entities, otherwise readability wins.
Related tools
FiveM Coordinates Finder & Vector Calculator
FiveM coordinate tool: convert between vector3, vector4, JSON formats. Calculate distance & midpoint between two points. Generate Lua code for GetEntityCoords/SetEntityCoords.
FiveM Server Resource & Performance Calculator
Calculate FiveM server resource usage, estimate CPU/RAM/bandwidth, get tick rate recommendations and optimization tips for your server setup.
FiveM Map Blip Creator - Visual Builder
Create FiveM map blips visually. Select sprite ID, color, scale, and label. Generate complete Lua code for CreateBlip with all settings. Preview blip sprite.