Best way to network serverside mesh for to client on entity creation? Alternative solutions welcome.

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()

  local vertices = self:GetPhysicsObject():GetMeshConvexes();
  for k, v in pairs(vertices[1]) do
    local point = ents.Create("info_point");
    if (!IsValid(point)) then return end


function ENT:Think()

(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.[/t]

All Hammer models are compiled into the map, and as such, are available under both, client and server.

GMod’s “brush” type entities are not brush at all, don’t even bother trying to use them, they are only meant to be used as trigger entities. ( Blame Garry )

What you need is “anim” type entity as a workaround. Here’s an example, my several years old GMod implementation of func_respawnroomvisualizer from TF2.

I have questions:

Why is it that every time I’ve tried using anim, it’s defaulted to an error.mdl at the world origin, if at all?

What are you using as a model?

As it stands, I’m not even getting it to spawn with any solidity. In console:

[SERVER]: CurTime:  235 
[SERVER]: GetPos:  0.000000 0.000000 0.000000 
[SERVER]: OBBMins + OBBMaxs:  -7.545272 -37.840000 0.000000 9.642241 44.751400 67.782997

That doesn’t resemble the size of my brush.


ENT.Base  = "base_anim";
ENT.Type  = "anim";


function ENT:Initialize()
  if (SERVER) then
    self:SetRenderBounds(self:OBBMins(), self:OBBMaxs());

function ENT:Draw()

function ENT:Think()
  DebugMsg("server",{"%V","CurTime: ",math.floor(CurTime())});
  DebugMsg("server",{"%V","GetPos: ",tostring(self:GetPos())});
  DebugMsg("server",{"%V","OBBMins + OBBMaxs: ",tostring(self:OBBMins()),tostring(self:OBBMaxs())});
  if (SERVER) then self:NextThink( CurTime() + 5 ); end
  if (CLIENT) then self:SetNextClientThink( CurTime() + 5 ); end
  return true;

hook.Add( "ShouldCollide", "breakable_barrier_col_check", function( ent1, ent2 )
  return true;
end )

Please read my post above? The model is set manually.

[editline]22nd August 2016[/editline]

(Because anim type ents are not really meant for this)

I misunderstood. So you’re saying I’m better off using actual models since I can position them in Hammer and get the right positioning in Garry’s Mod, right?

[editline]21st August 2016[/editline]

Oh whoops, I’m dumb. I didn’t realize you meant the brush itself is treated as a model. Sorry about that, thanks!