Hey there. I’m trying to make a brush-based forcefield entity to make stuff easy for mappers. It needs to be able to take damage and “break”.
To goal is to simply lay a brush out in Hammer and then use the information about the brush to create the forcefield. I’m not fond of the idea of forcing mappers to set up millions of overlapping brushes to achieve the same effect, when I can do the hard work to simplify the process.
The problem is that brush entities in Garry’s Mod seem to be reserved within the context of triggering events, and are only available server-side. The only way to grab the necessary information about the brush is to ensure that it is a brush entity. Suggestions that I change it to “anim” makes grabbing any information useless as it will default to the world origin with collisions that matches the error model.
ENT.Base = "base_entity"; ENT.Type = "brush"; function ENT:Initialize() self:PhysicsInit(SOLID_BSP); self:SetMoveType(MOVETYPE_NONE); self:SetSolid(SOLID_BSP); self:GetPhysicsObject():EnableMotion(false); local vertices = self:GetPhysicsObject():GetMeshConvexes(); for k, v in pairs(vertices) do local point = ents.Create("info_point"); if (!IsValid(point)) then return end point:SetPos(v.pos); point:Spawn(); end self:Remove(); end function ENT:Think() end
(info_point is a debugging entity I’ve chosen)
I have the mesh information from GetMeshConvexes(), and I can create an entity that has the mesh information upon initialization on the server only, but I have no idea how to ensure the client gets all the information the server does for rendering. I’m aware of the net library and how to use it, but I just need a logical run down of how it can be applied here.
Any ideas? I’ll post the finished product so people who want to work with brush entities can do so with a reference.