VDIST2
Returns the squared 3D distance between two points, which skips the square root and is cheaper for range checks.
Compare the result against the square of your range instead of calling VDIST.
Signature
float VDIST2(float x1, float y1, float z1, float x2, float y2, float z2); // 0xB7A628320EFF8E47 b1207Parameters
| # | Name | Type |
|---|---|---|
| 1 | x1 | float |
| 2 | y1 | float |
| 3 | z1 | float |
| 4 | x2 | float |
| 5 | y2 | float |
| 6 | z2 | float |
Facts
| Name | VDIST2 |
|---|---|
| Hash | 0xB7A628320EFF8E47 |
| Namespace | |
| Returns | float |
| Game build | 1207 |
Examples
Calls by hash work in every RedM runtime. Replace the placeholder arguments with your own values.
local result = Citizen.InvokeNative(0xB7A628320EFF8E47, -- VDIST2
0.0, -- float x1
0.0, -- float y1
0.0, -- float z1
0.0, -- float x2
0.0, -- float y2
0.0, -- float z2
Citizen.ResultAsFloat()
)
print(result)// Whole JS numbers are sent as integers: pass floats like 1.5 (or n + 0.0000001), never 1.
const result = Citizen.invokeNative("0xB7A628320EFF8E47", // VDIST2
0.0, // float x1
0.0, // float y1
0.0, // float z1
0.0, // float x2
0.0, // float y2
0.0, // float z2
Citizen.resultAsFloat()
);
console.log(result)float result = Function.Call<float>((Hash)0xB7A628320EFF8E47, // VDIST2
0.0f, // float x1
0.0f, // float y1
0.0f, // float z1
0.0f, // float x2
0.0f, // float y2
0.0f // float z2
);Related BUILTIN natives
Facts compiled from community research (alloc8or/rdr3-nativedb-data, femga/rdr3_discoveries); descriptions and examples by The Lab.