How to get distance from player to wall ?

I want to get the distance like from LocalPlayer():GetEyeTrace() and to the wall or a props.

I found something with OBBMax and OBBMins but i’m not sure about this.

Thanks in advance.

heres a simple code on how to get meters to the hit pos.
I found how much units one meter is on valves wiki somewhere.
MePos = LocalPlayer:GetPos() trace = LocalPlayer():GetEyeTrace() Hit = trace.HitPos Meter = 52.2448979591836734693877551020411 local DistanceToTarget = MePos:Distance(Hit) local DistanceToTarget = DistanceToTarget / Meter local DistanceToTarget = math.floor(DistanceToTarget)

Depends… Do you want the wall the player is facing or all the walls around him?

If you want the wall he’s facing use the above code. (without that dumb meters shit)

If you want all the walls around him use this code:

local pos = ply:GetPos()

for i = 1, 4 do
local ang = self:GetAngles() + Angle(0, i90, 0)
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+(ang
tracedata.filter = self.Owner
local trace = util.TraceLine(tracedata)
if trace.HitNonWorld or trace.HitWorld then
print(“hit a wall: i=”…i)
print(“1 = right, 2 = behind, 3 = left, 4 = forward”)
print("distance: "…pos:Distance(trace.HitPos))

Thanks but, I have a question about Distance() I tried to found it on gmod wiki because I already see that before but without info.

And if I want use it for hud it is server or client ?

about **[Vector.Distance](**


Where did yuriman get v:GetPos() from.

OK, I tested what iRzilla write, but I think the measure is not exact because I verified with wire ranger and I don’t have the same thing.

[LUA]function myhud(ply)
local client = LocalPlayer()
local self = player.GetByID( 1 )

local pos = self:GetShootPos()
local eyepos = self:GetPos()

local ang = self:GetAngles() + Angle(0, 90, 0)
local tracedata = {}
 tracedata.start = eyepos
 tracedata.endpos = eyepos + ang 
 tracedata.filter = self.Owner
 local trace = util.TraceLine(tracedata)

if !client:Alive() then return end

draw.RoundedBox(4, 25, 525, 180, 50, Color(0, 0, 0, 120))
draw.SimpleText( tostring (pos:Distance(trace.HitPos)) , "ScoreboardText", 40, 540, Color(255, 255, 255, 255), 0, 0)


hook.Add(“HUDPaint”, “myhud”, myhud)[/LUA]

the wire ranger uses the same function, also i edited the post forgot to change that.

Wire Ranger is inaccurate.