• Check if a vector is inside a brush entity?
    5 replies, posted
I have a brush entity called a krp_room, and I want to check if a vector ( x, y, z ) is inside the brush. Is there a function to do this?
Can't you just check if it's inside the brush box?
The brush isn't always a box shape, and can be made up of several brushes too.
[url]http://wiki.garrysmod.com/?title=Util.PointContents[/url] [url]http://wiki.garrysmod.com/?title=Util.IsInWorld[/url]
I'm not sure that I can use either for what I need, but thanks for searching. I think I may have to make an invisible entity at the point and use the StartTouch hook in the brush entity.
Untested but should work. shared.lua [lua]_R["Entity"].IsInsideEntity = function(self, ent) local origin = self:LocalToWorld(self:OBBCenter()) local entnearest = ent:NearestPoint(origin) return entnearest:Distance(self:NearestPoint(entnearest)) == 0 end[/lua] in your brush entity or whatever. [lua]if someentity:IsInsideEntity(self) then --whatever end[/lua]
Sorry, you need to Log In to post a reply to this thread.