daza 36 Posted January 10, 2010 How do you compare the distance of two objects vertically in a waituntil condition? Ive tried using getposasl of two objects then eg in condition obj1==obj2 but i get an error. Or would distance be just as sufficient? Im using distance at the moment, but i was hoping for more precise check. Its for a Helicopter land on Frigate script ive put together. Thanks Daza Share this post Link to post Share on other sites
Ghost 40 Posted January 10, 2010 http://community.bistudio.com/wiki/getPosASL you have to do something like the example from the link hint format["position above sea level: %1",(getPosASL player) select 2] select 0 = x, select 1 = y, select 2 = z so maybe something as follows if ((getposasl UNIT1) select 2) < (getposasl UNIT2) select 2)) then { hint format ["Unit1 is %1 \n Unit2 is %2", (getposasl UNIT1) select 2),(getposasl UNIT1) select 2)]; }; give it a shot, might need tweaking. Its late so I might not make much sense atm. Hope it helps anyway. Share this post Link to post Share on other sites
daza 36 Posted January 10, 2010 Thanks Ghost for your suggestion. Couldn't get it to work. Still i learnt something that was missing in the wiki, which is the select 0 = x, select 1 = y, select 2 = z you mentioned. It didnt like the syntax in the hintformat either, i haven't seen that method of use before. Anyway so what i did in the end, since you can land on the back of the ship was just checked when helicopter/pilot turned off engine and used that as my condition to show addaction option of securing chopper to deck. And it works. Share this post Link to post Share on other sites
Ghost 40 Posted January 10, 2010 yea sorry about that i forgot extra (. but it works just fine for me. No with that you could just subtract one from the other. But guess your other method is working so thats great! hint format ["Unit1 is %1 \n Unit2 is %2", ((getposasl UNIT1) select 2),((getposasl UNIT2) select 2)]; Share this post Link to post Share on other sites
galzohar 31 Posted January 11, 2010 waitUntil {abs ((getPosASL obj1 select 2) - (getPosASL obj2 select 2)) < _epsilon}; Where _epsilon is some small number, the bigger it is the more leeway you have in terms of height difference (that is, if _epsilon = 0.1 their height difference must be less than 10cm). If you just wait until they're equal they probably never will be, as positions are not round numbers and thus you should never assume that they would ever be equal. Abs makes it so that you get the actual (positive) z distance between them and not difference in their z values. Share this post Link to post Share on other sites