Hey there,
I'm attempting to trace a client side prop to my cursor. My cursor is unlocked [ gui.EnableScreenClicker(true) ] and I have some code, but its not quite what I'm looking for. I'm kinda going for the RTS "Placing" mechanic, where the object follows your mouse.
This is what I got, its not quite what I want, its in the center of my screen, when I want it to follow my cursor in the 3D environment. I feel like I'm really close, just one tiny thing off. I might be wrong.
util.PrecacheModel( "models/props_borealis/bluebarrel001.mdl" )
local tr = util.QuickTrace( LocalPlayer():GetShootPos(), gui.ScreenToVector( gui.MousePos() ), LocalPlayer() )
local c_Model = ents.CreateClientProp()
c_Model:SetPos( tr.HitPos )
c_Model:SetModel( "models/props_borealis/bluebarrel001.mdl" )
c_Model:SetParent(LocalPlayer())
c_Model:Spawn()
local pointertoworld = gui.ScreenToVector( gui.MouseX(), gui.MouseY() )
local tracetospace = util.QuickTrace(view.origin, pointertoworld * 10000, LocalPlayer())
c_Model:SetPos(tracetospace.HitPos)
Found a solution myself through much headache.
Sorry, you need to Log In to post a reply to this thread.