Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

util.TraceEntity doesn't take the entity's angles into account #1617

Closed ottworks closed 6 months ago

ottworks commented 9 years ago
local function entvalid(trace)
    local ent = trace.Entity
    if trace.Hit then
        if trace.HitWorld then
            return true
        end
        if IsValid(ent) then
            if ent:GetClass() == "prop_physics" then
                return true
            end
        end
    end
end

In my SWEP code...

local tr = util.TraceEntity({
    start = ent:GetPos(),
    endpos = ent:GetPos(), 
    filter = filter,
    mask = MASK_SHOT,
    }, 
ent)
if not entvalid(tr) then
    PrintTable(tr)
    obj:EnableMotion(true)
    obj:Wake()
end

Result: https://www.youtube.com/watch?v=U65xXY9Ker8

This pretty much makes util.TraceEntity useless.

ottworks commented 9 years ago

This is also why Garry makes this comment in the prop spawning code:

https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/gamemodes/sandbox/gamemode/commands.lua#L253-L255

willox commented 9 years ago

This is also why Garry makes this comment in the prop spawning code

That comment doesn't seem to suggest that TraceEntity doesn't work properly, but that the effect of the current method just feels nicer.

robotboy655 commented 9 years ago

This is pretty much how Source Engine has it, I don't think you will ever see a fix for this. Same goes for TraceHull.

Kefta commented 7 years ago

Yeah, Source just wasn't built to have rotatable hulls - a series of TraceLines is the closest you're going to get with the current functionality. Perhaps a new trace function that traces a rotated box/OBB could be possible.