Jump to content
Sign in to follow this  
SRBuckey5266

Teleport to roof?

Recommended Posts

If there is a building that has no stairs in it, but I want to teleport to the roof....how would I go about getting the correct height? I know how to write the script, but is there a way to make the script detect the correct height to put the player at? I don't want to spawn to high and die, or spawn to low and be stuck in the building.

Share this post


Link to post
Share on other sites

I'm unaware of any command to automate this, so would recommend you place a unit down in the editor and try to find the correct height manually. setPosATL works in meters, it shouldn't be too difficult. A command that snaps the height to the object collision box would be great.

Share this post


Link to post
Share on other sites

Yeah getting the collision box would ease the things considerably, but you could try to use something similar: boundingBox

Please note that the building needs to have a flat roof, if there are towers or something else sticking out of it, the boundingBox will be respectively higher and you'd fall from midair and crush your bones ^^

There another command named buildingPos which you could loop through and take the position with the highest Z-value, but thats more of a gamble though, since having a building position on the roof isn't mandatory.

Both ways are too unreliable and could cause more harm than good... I can remember to have read a thread about positioning AI on rooftops in this forum and I can remember that there was a script floating around for that... but I can't remember the thread name ^^

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

No, I searched for this before and couldn't find it. The closest you can get is BoundingBox which is always a lot higher than the building, and not really useful at getting a rooftop height. I ended up just making array of all the building heights I needed.

As a workaround you can do something like this

_boundsMin = boundingBox model select 0;
_boundsMax = boundingBox model select 1;
_buildingATL = GetPosATL _building select 2;

_boxHeight = (_boundsMax select 2)-(_boundsMin select 2);


Player allowdamage false;
//set the player's position to the boundingbox height
Player setPosATL [Position _building select 0,Position _building select 1,(Position _building select 2) +_boxHeight];
sleep 2; //wait for him to fall to the rooftop before enabling damage again.

Player allowdamage true;

Share this post


Link to post
Share on other sites

I use trigger for positioning objects on roofs such as static weapons and sandbags.

trig cond true

on act obj_name setpos getopos thistrigger

The advantage is that it is invisible and you can move it around and don't have to keep adjusting the height .

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×