util.TraceLIne malfunction?

I’m trying to make a weapon that shoots through walls. I have a trace in the middle of the action that checks if we’ve hit the same entity so one bullet doesn’t hit one entity several times as it passes through.



			Msg(tr.HitPos.x .. " ")
			Msg(tr.StartPos.x .. "
")
			self.dist = self.dist+1
			trace = {}
			trace.StartPos = tr.HitPos + (1-tr.Fraction)*10*self.dir
			trace.EndPos = tr.StartPos + 10*self.dir
			trace.Mask = MASK_SHOT
			Msg(trace.StartPos.x .. " ")
			Msg(trace.EndPos.x .. "
")
			tr = util.TraceLine(trace)
			Msg(tr.HitPos.x .. " ")
			Msg(tr.StartPos.x .. "
")


is the trace. Here’s the output for the first iteration, which makes the remainder nonsensical. Importantly, the last pair (the results of the trace) are always 0.

The first tr is determined via the bullet callback. self.dir is calculated by doing tr.HitPos-tr.StartPos, and then normalizing.

Why is a trace always telling me it’s hitting and starting at the origin, even when the startpos is nowhere near it?

http://wiki.garrysmod.com/page/Structures/Trace Read carefully. There’s no such thing as StartPos in the trace table you pass as argument to util.TraceLine, only in trace result

Welp. Never noticed that before.