• Checking where the map bounds are with LUA (or an alternative)
    4 replies, posted
I want to use a better position for my RenderView. Right now I'm using a position a few units up from the player's position, and don't call it if util.IsInWorld() is true. But all maps are different, so x amount of units up will be different each time. For instance, if you go into a building, I want the camera to be able to see well above the top, and always have it at that height (the height wouldn't change when you enter the building). Would I have to loop forever and slowly increment a vector until it's "in something"? Would util.IsInWorld() even return true if the vector was in the skybox? I just want the camera to be as high as possible for the map without weird stuff happening. If I have to loop until the vector "hits something", do I need to delay the spawning of players until it's calculated, or will it not even take that long (probabaly wont)?
Not sure if it works but have you tried getting the bounding box of the world entity? (http://wiki.garrysmod.com/page/game/GetWorld)
Wow! Thanks so much! Works like a charm. Went with this. local minh, maxh = game.GetWorld():GetModelBounds() local orig = LocalPlayer():GetPos() orig.z = maxh.z By the way, when I say I forgot to add a bounty, I mean that I checked the box but left it at 0. So it's still saying I can accept your answer. Huh... Anyways, here is that diamond.
This is exactly what i was wondering a few days ago before i made a hacky workaround. Thanks!
For future reference, if the map is not a cuboid shape, you can do some maths with PhysObj/GetMesh on the world's physics object.
Sorry, you need to Log In to post a reply to this thread.