• How to run a trace in the direction an entity is traveling.
    3 replies, posted
I am trying to run a trace in the direction an entity is travailing and I am having a difficult time getting it working. This is how I am trying to do it local pos = ent:GetPos() util.QuickTrace( pos, (pos + ent:GetVelocity():GetNormalized()) * 300 , ent ) I thought it would work the same way as running a trace based off of GetForward() but it is always returning an inconstant direction that does not coincide with the ents velocity. Does anyone have a way of doing this?
It looks like your math is wrong. You should be multiplying just the normalized velocity by 300 but you're multiplying pos + velocity * 300.
Thought so too but it provides the same result.
hook.Add("PostDrawTranslucentRenderables", "", function()     local ply = LocalPlayer()     local pos = ply:GetPos()     local vel = ply:GetVelocity()     local vec = vel:Angle():Forward()     render.DrawLine(pos, pos + vec * 300, Color(255, 0, 0)) end)
Sorry, you need to Log In to post a reply to this thread.