• Prevent props spawning in a map entity
    8 replies, posted
I'm trying to prevent props from spawning in a certain map entity which block the teams off from eachother. The map entity is func_wall_toggle so here is what I wrote. [lua] local pos = prop:GetPos() local min = prop:LocalToWorld(prop:OBBMins()+Vector(1.5,1.5,1.5))) local max = prop:LocalToWorld((prop:OBBMaxs()-Vector(1.5,1.5,1.5))) for i,v in pairs (ents.FindInBox(min, max)) do if v:GetClass() == "func_wall_toggle" then return end end [/lua] Now this works fine if the map only has one wall, but if it has multiple walls then it treats all the walls as one big entity and thus this function will think the prop lies within a func_wall_toggle even though it doesnt physically lie in it. To illustrate this I created an awesome paint picture. As you can see there are 2 func_wall_toggles and the bounding box for them is outlined in green. My prop obviously isn't intersecting with either wall but since it is treating them all as one then it thinks it is. I want to make it so the game knows when I'm actually intersecting with one of the walls. [IMG]http://i.imgur.com/jwSUa.png[/IMG]
You gotta find another way other than ents.FindInBox for sure, but what to use. I'll think about it.
I was hoping there was some function in gmod which checked to see if 2 entities were colliding. Something like ent1:ColldeWith(ent2). But since that would make my coding a lot easier, it probably doesnt exist. [editline]6th February 2011[/editline] Actually I have confirmed that it is how the map is made. If when the func_wall_toggles were each made 1 by 1 then my function works. If they were all selected and then made into a func_wall_toggle then it is treated like one giant entity. There has got to be some way around this
This maybe ? [url]http://luasearch.overvprojects.nl/?keywords=Entity.Touch[/url]
Thanks, but that didn't work. It still thinks it is touching it. [editline]6th February 2011[/editline] actually it didnt even sense that it was touching a func_wall_toggle
No other ideas?
You could make an entity that rather then being a physical dividision it would just remove any prop that touched it which didn't belong to the same team. Some thing like OnTouch (ent) if self.MyTeam != ent.Owner:team() then ent:remove() end end --This wont work btw
[QUOTE=S W;27897225] If they were all selected and then made into a func_wall_toggle then it is treated like one giant entity. [/QUOTE] Maybe because it actually becomes one entity?
I've had a lot of bad luck with this, but maybe it will work for you? [url]http://wiki.garrysmod.com/?title=PhysObj.IsPenetrating[/url]
Sorry, you need to Log In to post a reply to this thread.