• util.traceline/traceHull/traceEntity issue
    2 replies, posted
I was having a problem with tracelines so I decided to make a basic script as shown below concommand.Add("velo", function(ply) local pos = ply:GetPos() local yaw = ply:EyeAngles().y local traceData = {} traceData.startpos = pos + Vector(0, 0, 32) traceData.endpos = pos + Angle(0, yaw, 0):Forward() * 47 traceData.filter = ply local tr = util.TraceLine(traceData)     ply:SetPos(tr.HitPos) ply:PrintMessage(HUD_PRINTTALK, "Start Position: "..tostring(pos).."\nDesired Position: "..tostring(pos).."\nActual Position: "..tostring(tr.HitPos).. "\nEntity: "..tostring(tr.Entity).."\n--------------------------------------------------------------") end) (Some code influenced by ulx teleport.lua) The main purpose of the script is to teleport the user 47 units in front them across the x/y axis and print them results about the trace. The problem is this isn't really the case as many times it teleport the player far more then 47 units away and sometimes across the z axis (often to Vector (0, 0, 0) or inside a wall). Here is a screen shot of the print results Start Position is the startpos of the trace Desired Position is the endpos of the trace Actual Position is the actual position the the trace hits (according to tr.HitPos) As you can see definitely not around 47 units and shifting across the z axis when it shouldn't. The script is located in lua/autorun/server. Does anyone know why this happens?
It's not tracedata.startpos, it should be tracedata.start http://wiki.garrysmod.com/page/Structures/Trace
Thank you. Knew it had to be something silly like that.
Sorry, you need to Log In to post a reply to this thread.