Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local snappos
- local snapent
- concommand.Add("+ohsnap", function(ply)
- local res = ply:GetEyeTrace()
- if IsValid(res.Entity) then
- snapent = res.Entity
- snappos = snapent:WorldToLocal(res.HitPos)
- else
- snappos = res.HitPos
- end
- end)
- concommand.Add("-ohsnap", function()
- snappos = nil
- snapent = nil
- end)
- local pos
- local ang
- hook.Add("CalcView", "ohsnap:CalcView", function(ply, origin)
- if not snappos then return end
- if IsValid(snapent) then
- pos = snapent:LocalToWorld(snappos)
- else
- pos = snappos
- end
- ang = (pos - origin):Angle()
- ply:SetEyeAngles(ang)
- if snappos then
- return {angles = ang}
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment