I'm wanting to make a cover system for a gamemode and i need to check if a player is near a wall so that they can attach to it.Also how would i check for corners and edges.
Im guessing you will need to do traces, while not in cover do traces in a circle from the center of the player (waist height), looking for them to hit the world you would find your walls.
[url]http://wiki.garrysmod.com/?title=Trace[/url]
[url]http://wiki.garrysmod.com/?title=TraceRes[/url] (specifically, HitWorld)
For the corners you do something similair, you make traces alongside the plane of the brush your 'attached too' (see HitNormal in that TraceRes wiki) in a 90' offset to the brush your leaning against
you would more than likely need to use if ply:IsInSphere() or something like that
[editline]06:09PM[/editline]
[b][url=http://wiki.garrysmod.com/?title=Ents.FindInSphere]Ents.FindInSphere [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[editline]06:15PM[/editline]
UNTESTED but should work
[CODE]
function CheckForPlayers()
local brush = ents.FindByName("MyLuaBrush") // it will have to be a func_brush in the map, and nto a normal brush, then name it MyLuaBrush
local postentities = { }
if #brush == 1 then
local brush2 = brush[1]
local players = ents.FindInSphere( brush2:GetPos() , 60 )
for k,v in pairs( players ) do
if players:IsPlayer then
table.insert( postentities , v )
end
end
end
end
[/CODE]
[editline]06:15PM[/editline]
OUPS, sorry, thourhgt you were asking something else :3 rate me dumb
Sorry, you need to Log In to post a reply to this thread.