Map Height

How could you get the the dimensions of the map? I atleast need to be able to get the height. I am trying to do a trace to check if a path from the top of the map is clear to a position somewhere on the map, and I don’t know where that top of the map is.

Try out random positions and trace upwards until you find one that hits the skybox.

I asked about this the other day in the “What Do You Need Help With” thread, and didn’t get a reply, so I figure there are two ways around not being able to get the size of the world,

  1. Send a trace up and if it hits something other than skybox, go a little further and send another trace, etc, etc, until it hits sky. Probably do this once on map load or GM:Initialize(). This is probably a bad idea, but if you can’t edit the map #2 won’t work.

  2. If it’s your map place an info_landmark at the top of the map and just check it’s z position. I used something like this for my meteor gamemode i’m working on.

If there is a way to actually get the dimensions of the map via lua I would like to know too.

[lua]
sky = {};

local SKY_POSITION;

– Call this to get the position of the sky.
function sky.GetPosition()
if (!SKY_POSITION) then
sky.FindPosition();
end;

return SKY_POSITION;

end;

– Call this once somewhere to find the position.
function sky.FindPosition()
if (!SKY_POSITION) then
local curPos = Vector(0, 0, 0);

	while (true) do
		local traceLine = util.TraceLine( {
			start = curPos,
			endpos = curPos + Vector(0, 0, 128)
		} );
		
		if (!traceLine.HitSky) then
			curPos = curPos + Vector(0, 0, 128);
		else
			curPos = traceLine.HitPos;
			break;
		end;
	end;
	
	SKY_POSITION = curPos;
end;

end;

[/lua]

…or something.

Wasn’t there a function to get the map bounds?

eg

Can’t you just try to get the model bounds of worldspawn?

Unfortunately you can not, I’ve tried, OBBMins(), OBBMaxs(), and BoundingRadius() they all return 0’s.

I did some testing on this, and it turns out you can get the renderbounds of the map client-side.
So just query the first player who joins the server for the map bounds.