prevent setpos from teleporting player inside walls

I’m using this code to be able to set the players position while they are alive:



	concommand.Add("test1", function(ply)
    ply:SetPos(ply:GetPos() + ply:GetForward()*70)
	end)


If I’m next to a wall the player will get stuck inside the wall. How do I prevent this?

Do a

util.PointContents check to see if the teleporting location it contains anything.

Or if you want them to hit obstacles:
[lua]
local tr = util.TraceHull({
start = ply:GetPos(),
endpos = ply:GetPos() + ply:GetForward()*70,
mins = ply:OBBMins(),
maxs = ply:OBBMaxs(),
filter = ply,
})
ply:SetPos(tr.HitPos)
[/lua]