traceres.FractionLeftSolid Is Broken

The trace result data “FractionLeftSolid” is supposed to calculate when the trace left the solid it started in, as a fraction of the total trace length. I tried using this function with every trace function on the wiki, using many different combinations of filters and masks, and I could not get it to work. When a trace hits a solid object, it stops. So when a trace starts in a solid object, it doesn’t go anywhere, and can’t determine when it left the solid. From what I can tell, Traces cannot leave solids.

If i’m missing something or you have a solution, please respond. Thanks :frowning:


edit: Below is a simple testing SWEP I made to see if anything works. It scrolls through every collision type, and for each collision type, draws a trace for each mask type and prints the FractionLeftSolid. I ended up with 441 zeros in the console.


[swep code swep code swep code blah blah blah]

function SWEP:Initialize()

SetGlobalInt(“mask1”, 4294967295)
SetGlobalInt(“mask2”, 16449)
SetGlobalInt(“mask3”, 33570881)
SetGlobalInt(“mask4”, 16515072)
SetGlobalInt(“mask5”, 65547)
SetGlobalInt(“mask6”, 33701899)
SetGlobalInt(“mask7”, 147467)
SetGlobalInt(“mask8”, 131083)
SetGlobalInt(“mask9”, 16513)
SetGlobalInt(“mask10”, 33570945)
SetGlobalInt(“mask11”, 33636363)
SetGlobalInt(“mask12”, 81931)
SetGlobalInt(“mask13”, 1174421507)
SetGlobalInt(“mask14”, 100679691)
SetGlobalInt(“mask15”, 33570819)
SetGlobalInt(“mask16”, 33570827)
SetGlobalInt(“mask17”, 16395)
SetGlobalInt(“mask18”, 48)
SetGlobalInt(“mask19”, 24705)
SetGlobalInt(“mask20”, 33579137)
SetGlobalInt(“mask21”, 16432)

end

local function IsExistant(input)
if IsValid(input) and input:IsValid() and input != nil and !input:IsWorld() then
return true
else
return false
end
end

local testtab = {}

function SWEP:PrimaryAttack() // Selects the entities.
local ent = self.Owner:GetEyeTrace().Entity
if !IsExistant(ent) then return end

if table.Count(testtab) < 2 then
    table.insert(testtab, ent)
    print("Entity "..ent:EntIndex().." selected!")
    print("  Position: "..tostring(ent:GetPos()))
end

end

function SWEP:SecondaryAttack() // Scrolls through every collision type and, for each collision type, creates a trace for each mask type.
if table.Count(testtab) != 2 then return end

for i = 0, 20 do
    testtab[1]:SetCollisionGroup(i)

    for j = 1, 21 do
        local tracedata = {}
        tracedata.start = testtab[1]:GetPos()
        tracedata.endpos = testtab[2]:GetPos()
        tracedata.mask = GetGlobalInt("mask"..tostring(j))
        local trace = util.TraceLine(tracedata)
        print(tostring(trace.FractionLeftSolid))
    end
end
table.Empty(testtab)

end