• prevent setpos from teleporting player inside walls
    2 replies, posted
I'm using this code to be able to set the players position while they are alive: [code] concommand.Add("test1", function(ply) ply:SetPos(ply:GetPos() + ply:GetForward()*70) end) [/code] If I'm next to a wall the player will get stuck inside the wall. How do I prevent this?
Do a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/PointContents]util.PointContents[/url] 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]
Sorry, you need to Log In to post a reply to this thread.