Boborish 1 Posted July 25, 2008 Dont know how many of you noticed it, but setPosASL and getPosASL arent really working when you are in buildings. Ill explain on examples: GetPosASL Lets say youre outside a building. The getPosASL command shows, that you are 19 meters above the sea. Now you enter the building, walk several floors upstairs and getPosASL STILL returns 19 meters above the sea. SetPosASL Lets say youre on the roof of a building and know your REAL ASL height (19 meters to the ground, another 8 is the height of the buildings = 27m). You use setPosASL [position player select 0,position player select 1,27]. Now what happens? You appear in the air above the building, fall down and die. It seems that setPosASL first finds the ASL height of the ground itself (19m), subtracts it (27-19=8) ... now there still are 8 meters. The game finds the highest contact (in this case its the roof of the building) and sets you 8 meters above it. Now, heres the way, how to get rid of this issue. setRealASL.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/****************************************************************************** Script by Boborish (boborish@gmail.com) Sets the ASL position of a given object. Example of use: [soldier1,[5000,5000,30]] call compile preprocessFile "setRealASL.sqf" *******************************************************************************/ private ["_object","_newPos","_helpLogic"]; _object = _this select 0; _newPos = _this select 1; _helpLogic = "Logic" createVehicle (position _object); _helpLogic setPos [_newPos select 0,_newPos select 1,0]; _object setPos [_newPos select 0,_newPos select 1,(_newPos select 2) - (getPosASL _helpLogic select 2)]; deleteVehicle _helpLogic; getRealASL.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/****************************************************************************** Script by Boborish (boborish@gmail.com) Returns the ASL position of a given object. You need to find a selection in the object's model, should be as close to the center of the object as possible. But since there might be an offset between the given selection position and the objects land contact, there's a _zOffset parameter. For example: [soldier1,"head",-0.72] call compile preprocessFile "getRealPos.sqf" returns the accurate ASL position of a soldier named soldier1. *******************************************************************************/ private ["_object","_selection","_zOffset","_helpLogic","_z","_return"]; _object = _this select 0; _selection = _this select 1; _zOffset = _this select 2; _helpLogic = "Logic" createVehicle (position _object); _helpLogic setPos [position _object select 0,position _object select 1,0]; _z = ((_object modelToWorld (_object selectionPosition _selection)) select 2) + (getPosASL _helpLogic select 2) + _zOffset; deleteVehicle _helpLogic; _return = [position _object select 0,position _object select 1,_z]; _return Share this post Link to post Share on other sites
Gargantua 0 Posted July 25, 2008 confirmed old bug i remember GetPosASL-SetPosASL combination was setting unit under the bridge he was staying on. i'd use old ofp scripting methods to get absolute height Share this post Link to post Share on other sites
Boborish 1 Posted July 25, 2008 That still wouldnt work in/on buildings, because getPos returns the height to the nearest contact beneath the object (=floor). ModelToWorld returns the real height (=ground). Share this post Link to post Share on other sites
Gargantua 0 Posted July 25, 2008 olf ofp technics were not just getpos i can't remember exactlpy but with several triggers/fake models and distance command ASL could be set well in ofp... i guess it will work in arma too. Share this post Link to post Share on other sites