Jump to content
Sign in to follow this  
CarlGustaffa

Obtaining altitude AGL without using attachTo, how?

Recommended Posts

Hi

Trying to make a system where AI crew guides player pilot to do a CH-47 pinnacle landing, but I'm having problems at the very basics, lol.

If I do this:

uRampObject = "Roadcone" createvehicle [0,0,0];
uRampObject attachTo [heli, [0, -7, -3]];

I can get height of the object using getPos uRampObject select 2; which counters for buildings (usually, but I'm expecting the old stacking bug to kick in on rare circumstances).

But how do I do this if I want to avoid using an additional object to reference from? From any 2D pos I supply, how do I get a altitude above object? Basically instead of a getTerrainHeightASL, I want some sort of getBuildingHeightASL command. Is this possible?

Share this post


Link to post
Share on other sites

I think they use those to create "building markers" on the map for the town generator.

But yes, seems like there is no other good way but to use an object ref.

Seems to be working ok, but I struck another weird issue. The first seems to work, but I can't spot the error on the second:

if(!isNull _nearest && ((typeof _nearest) in _possible_types) && ((position _vec) select 2 > 2.5)) then {_check_type = 1}; //works ok
//_check_type = (if(!isNull _nearest && ((typeof _nearest) in _possible_types) && ((position _vec) select 2 > 2.5)) then {1}); //fails, but why?

I also tried not encapsulating everything, but same result. Just messing around in the Domination chopper hud.

Share this post


Link to post
Share on other sites

I believe you need an if/else statement for it to work. If the conditions aren't met, it won't know what to do with the variable if there is no else.

Share this post


Link to post
Share on other sites

Yeah, that seems to do the trick, thx. Yes, tried with then {1};); as well without success. But, is this logical? In the working case I'm also not providing an else {}; statement, _check_type already have a number assigned so it should just skip it and keep the original value.

What I ended up with that worked:

_check_type = (if(!isNull _nearest && ((typeof _nearest) in _possible_types) && ((position _vec) select 2 > 2.5)) then {1} else {_check_type});

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  

×