# Function for inside Building

## 10 posts in this topic

hello there,

i wonder if theres some function out there to check if a given unit or object is inside a Building?

Triggers would work.. but i heard they use a lot of perfomance and I already got lots of triggers(which indeed use alot perfomance)

My tries were to use the boundingboxes , but they seem to be very inaccurate and most times double the size of the building.

I also started a Topic in bohemia forum, but maybe someone here knows some way.

Edited by hieve

#### Share this post

##### Share on other sites

I use a combination of checks. So adding a check to the exile thread I check for building within 8m then I check altitude of player above ground. As when u enter a building your altitude is always I think off top of my head greater than 0.3m. On land it's less

1 person likes this

#### Share this post

##### Share on other sites
Advertisement
1 hour ago, happydayz said:

I use a combination of checks. So adding a check to the exile thread I check for building within 8m then I check altitude of player above ground. As when u enter a building your altitude is always I think off top of my head greater than 0.3m. On land it's less

ok, but you could stand next to a building and this would say youre inside?

i have tried distances, but distance won't work as a building has different shapes, like a rectangle, so you got a X and Y axis, where a distance is just one variable.

what you mean by entering its higher? like every building has a Z offset of like 0.3m?

#### Share this post

##### Share on other sites

Every building has a height above ground level greater than about 0.3 due to it's floor. The 8m is due to it taking distance to building from a buildings centre and some buildings like the factories etc are large. By combining checks you can get a fairly accurate idea if you are in a building

#### Share this post

##### Share on other sites
16 hours ago, happydayz said:

Every building has a height above ground level greater than about 0.3 due to it's floor. The 8m is due to it taking distance to building from a buildings centre and some buildings like the factories etc are large. By combining checks you can get a fairly accurate idea if you are in a building

tried this.

just the prob which such value is..

when you standing next to a building that has a uphill , youre much higher than the building or even on the same level.

also some buildings may have no floor (like the slum houses on altis)

Edited by hieve

#### Share this post

##### Share on other sites

dont compare your height to the buildings height. just do a check for YOUR current height atl. like this:

```	_pos = getposatl player;
_height = _pos select 2;
_nearbuilding = nearestObjects [player, ["House", "Building"], 8] select 0;
if ((isNil "_nearbuilding") && (_height < 0.13)) then
{```

#### Share this post

##### Share on other sites
11 hours ago, happydayz said:

dont compare your height to the buildings height. just do a check for YOUR current height atl. like this:

```
_pos = getposatl player;
_height = _pos select 2;
_nearbuilding = nearestObjects [player, ["House", "Building"], 8] select 0;
if ((isNil "_nearbuilding") && (_height < 0.13)) then
{```

ah ok! still not sure if its good to use a fixed height here

someone replied in bohemia forums and gave me a hint what could be used

and there is excatly what i needed:

Spoiler

Posted on August 27, 2015 - 12:44 (UTC)

Killzone Kid

Fast check if object is in a house:

KK_fnc_inHouse = {
lineIntersectsSurfaces [
getPosWorld _this,
getPosWorld _this vectorAdd [0, 0, 50],
_this, objNull, true, 1, "GEOM", "NONE"
] select 0 params ["","","","_house"];
if (_house isKindOf "House") exitWith {true};
false
};
onEachFrame {hintSilent str (player call KK_fnc_inHouse)};

Edited by hieve

#### Share this post

##### Share on other sites

onEachFrame ----- wow.......

#### Share this post

##### Share on other sites

Just use EXILE's check for under cover , take from ExileClient_object_player_stats_updateTemperatur.sqf

```_startPosition = getPosASL player;
_endPosition = [_startPosition select 0, _startPosition select 1, (_startPosition select 2 ) + 10];
_intersections = lineIntersectsSurfaces [_startPosition, _endPosition, player, objNull, false, 1, "GEOM", "VIEW"];
_isBelowRoof = !(_intersections isEqualTo []);```

This'll check if a player is under any kind of cover. Not specifically a building but, eh.. maybe itll work

#### Share this post

##### Share on other sites
10 hours ago, happydayz said:

onEachFrame ----- wow.......

not the best yeah, there should be better something like onPositionUpdate, but this here is really important that it will never get executed if someones in a building

10 hours ago, John said:

Just use EXILE's check for under cover , take from ExileClient_object_player_stats_updateTemperatur.sqf

```
_startPosition = getPosASL player;
_endPosition = [_startPosition select 0, _startPosition select 1, (_startPosition select 2 ) + 10];
_intersections = lineIntersectsSurfaces [_startPosition, _endPosition, player, objNull, false, 1, "GEOM", "VIEW"];
_isBelowRoof = !(_intersections isEqualTo []);```

This'll check if a player is under any kind of cover. Not specifically a building but, eh.. maybe itll work

ah nice that exile got some in there already  didn't had the time to check all exile files until now(too much)

if someones interested how these type of things are working:

looks like GEOM can define collision points, so you could do here alot things(maybe some type of trap? idk... another source for ideas)

Edited by hieve

Advertisement

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• ### Recently Browsing   0 members

No registered users viewing this page.