How to detect if a player is walking on the skybox?
4 replies, posted
I want players to die if they walk on the skybox. Here's the code I tried which didn't work.
[lua]function GM:Tick()
for _, v in pairs( player.GetAll() ) do
if ( !v:Alive() ) then return end
tr = { }
tr.start = v:GetPos() + Vector( 0, 0, 1 )
tr.endpos = tr.start - Vector( 0, 0, 32 )
tr.filter = v
if ( !tr.Hit ) then return end
if ( tr.HitSky ) then v:Kill() end
end
end[/lua]
Anyone knows how to fix it?
How didn't it work? Are you sure it's all being called?
Msg() in every logic statement. Where does it get to?
You didn't actually run the trace.
[lua]function GM:Tick()
for _, v in pairs( player.GetAll() ) do
if ( !v:Alive() ) then return end
local tr = {} -- You really need to use locals
tr.start = v:GetPos() + Vector( 0, 0, 4 )
tr.endpos = tr.start - Vector( 0, 0, 32 )
tr.filter = v
local trace = util.TraceLine(tr) -- You didn't actually run the trace
if ( !trace.Hit ) then return end
if ( trace.HitSky ) then v:Kill() end
end
end[/lua]
Damn it, it's always the small little things I forget that confuse me to hell and back >:( Thanks :v:
Sorry, you need to Log In to post a reply to this thread.