How can you detect an interception between two traces?

I’m trying to figure out how to detect a trace hitting another trace that’s coming up from an entity on the ground.

How can you detect if your eye trace is hitting the other trace that’s coming out of the weapon, and is it possible to make a trace thicker?

Intersection, you mean.

Two segments in 3D space will very rarely collide. But, since you’re wanting to “thicken the traces”, you can use an algorithm to find the shortest distance between the two traces, and set a threshold value to determine whether or not it should be considered collision.

Here’s a video that should help you out some.

Yeah I meant Intersection

[del]I might just end up doing a quick hack instead and make an invisible entity like a cylinder inside the other entity and detect the collision like that instead.[/del]

Try messing around with vector functions, such as :Dot ot :Cross

I’ll try both of these methods but I think the dot product should do the trick, thanks guys!

Thanks! That code snippet at the bottom helped, here is the conversion to lua which I used:
[lua]
local math = math
local abs = math.abs
local SMALL_NUM = 0.00000001

local function dist3D_Segment_to_Segment(segment1P1, segment1P2, segment2P1, segment2P2)
local u = segment1P2 - segment1P1
local v = segment2P2 - segment2P1
local w = segment1P1 - segment2P1
local a = u:Dot(u) // always >= 0
local b = u:Dot(v)
local c = v:Dot(v) // always >= 0
local d = u:Dot(w)
local e = v:Dot(w)
local D = ac - bb // always >= 0
local sc,sN,sD = D, D, D, D // sc = sN / sD, default sD = D >= 0
local tc,tN,tD = D, D, D, D // tc = tN / tD, default tD = D >= 0

// compute the line parameters of the two closest points
if (D < SMALL_NUM) then // the lines are almost parallel
	sN = 0.0         // force using point P0 on segment S1
	sD = 1.0         // to prevent possible division by 0.0 later
	tN = e
	tD = c
else // get the closest points on the infinite lines
	sN = (b*e - c*d)
	tN = (a*e - b*d)
	if (sN < 0.0) then // sc < 0 => the s=0 edge is visible
		sN = 0.0
		tN = e
		tD = c
	elseif (sN > sD) then // sc > 1  => the s=1 edge is visible
		sN = sD
		tN = e + b
		tD = c
	end
end

if (tN < 0) then // tc < 0 => the t=0 edge is visible
	tN = 0
	// recompute sc for this edge
	if (-d < 0) then
		sN = 0
	elseif (-d > a) then
		sN = sD
	else
		sN = -d
		sD = a
	end
elseif (tN > tD) then      // tc > 1  => the t=1 edge is visible
	tN = tD
	// recompute sc for this edge
	if ((-d + b) < 0) then
		sN = 0
	elseif ((-d + b) > a) then
		sN = sD
	else
		sN = (-d +  b)
		sD = a
	end
end
// finally do the division to get sc and tc
sc = ((abs(sN) < SMALL_NUM) and 0) or (sN/sD)
tc = ((abs(tN) < SMALL_NUM) and 0) or (tN/tD)

// get the difference of the two closest points
local dP = w + (sc * u) - (tc * v)  // =  S1(sc) - S2(tc)

return dP:Length()   // return the closest distance

end
[/lua]