Entity visibility
McGlaspie
www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
in Modding
Yo,
Just wanted to ask some of the folks here that have had more experience with NS2 than I have (pertaining to Lua). Is there a simple way to determine if an entity is visible on screen? I don't really care if the entity's model should be visible or not, but rather if the entity is currently visible in a player's camera viewpoint.
Thanks.
Just wanted to ask some of the folks here that have had more experience with NS2 than I have (pertaining to Lua). Is there a simple way to determine if an entity is visible on screen? I don't really care if the entity's model should be visible or not, but rather if the entity is currently visible in a player's camera viewpoint.
Thanks.
Comments
Only some of them are invisible, why do you need to see them ?
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>function GetEntitiesInViewFunctor(player, functor)
local entities = {}
local startEntity = nil
local currentEntity = nil
repeat
currentEntity = Shared.FindNextEntity(startEntity)
if currentEntity and currentEntity:isa("ScriptActor") then
if(functor(currentEntity)) then
if(player:GetCanSeeEntity(currentEntity)) then
table.insert(entities, currentEntity)
end
end
end
startEntity = currentEntity
until currentEntity == nil
return entities
end</div>
I think it should work with some very minor modifications. Now, I wonder if I can tag this inside of Client.OnPostRender()...we'll find out soon enough.
Edit: Btw, I realize how potentially slow this could be, and I see it will poll damn near every active entity in the game. That's why I said "with some modifications".
So much for that idea.