thy_ 164 Posted March 2, 2022 I'm finishing a script to release soon but I am facing an annoying bug around isTouchingGround I guess. // scope: checking if the "special boxes" are in good conditions: // _specialBox = _x; if ( !(isTouchingGround _x) OR (underwater _x) OR (speed _x > 0) ) exitWith { ["The box doesn't meet the conditions to work!"] remoteExec ["systemChat", _eachHumamPlayer]; }; What I expect: if the box/object is NOT touching the ground, or is under the water, or even is moving, that message above MUST shows up to the player. What is happening now: Even the object touching the ground, not underwater and totally stopped, the message is running for the player. Tests: If I remove just that piece "!(isTouchingGround _x)" everything runs as fine as possible with that important feature missing. I already checked the syntax and looks correct. I did a few investigations (below) about isTouchingGround bugs but no clue what exactly I am facing here. https://www.reddit.com/r/armadev/comments/fal7ko/whats_wrong_with_my_code/ https://forums.bohemia.net/forums/topic/149495-istouchingground-help-needed/ What am I missing? Share this post Link to post Share on other sites
Larrow 2822 Posted March 3, 2022 Just check that its model [0,0,0] position above ground is smaller than its absolute boundingbox min height. _specialBox = cursorObject; _centerHeight = abs ( boundingBoxReal _specialBox select 0 select 2 ); _isTouchingGround = _specialBox modelToWorld[0,0,0] select 2 <= _centerHeight; 1 Share this post Link to post Share on other sites
pierremgi 4886 Posted March 3, 2022 Is your object attached to another one? Like Crate under parachute? Share this post Link to post Share on other sites
thy_ 164 Posted March 3, 2022 Hey, @pierremgi 3 hours ago, pierremgi said: Is your object attached to another one? Like Crate under parachute? No. It's a container being transported by helicopter. @Larrow, probably I did something wrong because it didnt work adapted in my script. 11 hours ago, Larrow said: Just check that its model [0,0,0] position above ground is smaller than its absolute boundingbox min height. _specialBox = cursorObject; _centerHeight = abs ( boundingBoxReal _specialBox select 0 select 2 ); _isTouchingGround = _specialBox modelToWorld[0,0,0] select 2 <= _centerHeight; To make it easier, here is the issue in VR map: https://drive.google.com/file/d/1yDAiZ6hquSdTCFzFs7qb5ov2_9czitJp/view?usp=sharing When the ammo box/container is under the water (or almost completely under the water), it must be NOT available. When the ammo box/container is flying for any reason, it must be NOT available. the main file: fn_VO_coreGround.sqf Spoiler private ["_arrayGrdRearmAssets","_groundVehicles","_serviceInProgress","_eachGrdVeh","_eachHumamPlayer","_centerHeight","_isTouchingGroundNoBug"]; if ( !groundVehiclesOverhauling ) exitWith {}; // GROUND SERVICES CORE [] spawn { _arrayGrdRearmAssets = []; _serviceInProgress = false; if ( VO_groundServRearm ) then { { _arrayGrdRearmAssets = _arrayGrdRearmAssets + allMissionObjects _x } forEach VO_grdRearmStationAssets }; { _x setAmmoCargo 0; } forEach _arrayGrdRearmAssets; while { VO_groundServRearm } do { // check who's human here: call THY_fnc_VO_humanPlayersAlive; { // VO_humanPlayersAlive forEach starts... _eachHumamPlayer = _x; // defining the ground veh of _eachHumamPlayer into XXm radius: _groundVehicles = _x nearEntities [VO_grdVehicleTypes, 10]; { // forEach of _groundVehicles starts... _eachGrdVeh = _x; // GROUND REARM { // forEach of _arrayGrdRearmAssets starts.... // checking the basic station condition: if ( (VO_groundServRearm) AND (alive _x) AND ( (_eachGrdVeh distance _x) < VO_grdActRange ) AND (_eachGrdVeh != _x) ) then { // checking the station even more: _x = cursorObject; _centerHeight = abs ( boundingBoxReal _x select 0 select 2 ); _isTouchingGroundNoBug = _x modelToWorld[0,0,0] select 2 <= _centerHeight; if ( /* (_isTouchingGroundNoBug == false) OR */ ( underwater _x ) OR ( speed _x > 0 ) ) exitWith { ["The station doesn't meet the conditions to work!"] remoteExec ["systemChat", _eachHumamPlayer]; }; if ( (alive _eachGrdVeh) AND ( ({getNumber (configFile >> "CfgMagazines" >> _x select 0 >> "count") != _x select 1} count (magazinesAmmo _eachGrdVeh)) > 0 ) AND (speed _eachGrdVeh < 2 AND speed _eachGrdVeh > -2) AND (_serviceInProgress == false) ) then { _serviceInProgress = true; sleep 2; ["Checking the vehicle ammunition..."] remoteExec ["systemChat", _eachGrdVeh]; sleep 3; playSound3D ["a3\sounds_f\sfx\ui\vehicles\vehicle_rearm.wss", _eachGrdVeh]; [_eachGrdVeh, 1] remoteExec ["setVehicleAmmo", _eachGrdVeh]; sleep 2; ["Vehicle has been rearmed!"] remoteExec ["systemChat", _eachGrdVeh]; sleep 3; _serviceInProgress = false; }; }; } forEach _arrayGrdRearmAssets; } forEach _groundVehicles; } forEach VO_humanPlayersAlive; sleep 5; }; // while-looping ends. }; // spawn ends. Share this post Link to post Share on other sites
pierremgi 4886 Posted March 3, 2022 It seems isTouchingGround works for car (good results, sling loaded or not), but not for Taru pods, Huron pods, cargo nets... Very strange and unreliable command. Roughly, use getpos yourCargo #2 <2 or even getPosATL yourCargo #2 <2 (referring to bottom of the sea, so not touching ground if not sunk) 1 Share this post Link to post Share on other sites
opusfmspol 282 Posted March 3, 2022 Maybe this post from 2016 could be relevant. isTouchingGround also has a note from Gippo dated April 2017 saying: Quote Be aware: it is not reliable on remote objects. Which in my mind would conflict with its Global Argument indicator; usually a command that needs to be run on the machine where object is local would have a Local Argument indicator. I concur with the @Larrow and @pierremgi, if the command is being problematic, rely on the object's z-coordinate instead. Share this post Link to post Share on other sites
thy_ 164 Posted March 3, 2022 🙂 // checking the mobile stations are in good conditions to work: // _eachGrdStation = _x; if ( (underwater _x) OR !((getPos _x) select 2 < 1) OR (speed _x > 0) ) exitWith // <<---- "!(isTouchingGround)" is not working reliable! { ["The station doesn't meet the conditions to work! Try later..."] remoteExec ["systemChat", _eachHumamPlayer]; }; What's happening above: if the ammo container ("a rearm station") is under the water.... or .... it is flying ..... or ..... it is moving, a message comes to the specific player. This worked pretty well in hosted server. Tonight I'll test on the dedicated server and later I come back with the results. Share this post Link to post Share on other sites
Larrow 2822 Posted March 4, 2022 14 hours ago, thy_ said: probably I did something wrong because it didnt work adapted in my script. As you left cursorObject in there, you were meant to replace this with your specialBox. Its not the object anyone is looking at(cursorObject) but the current box your checking so _x in your larger script. if ( (VO_groundServRearm) AND (alive _x) AND ( (_eachGrdVeh distance _x) < VO_grdActRange ) AND (_eachGrdVeh != _x) ) then { // checking the station even more: _centerHeight = abs ( boundingBoxReal _x select 0 select 2 ); _isTouchingGround = _x modelToWorld[0,0,0] select 2 <= _centerHeight; if ( !_isTouchingGround OR ( underwater _x ) OR ( speed _x > 0 ) ) exitWith { ["The station doesn't meet the conditions to work!"] remoteExec ["systemChat", _eachHumamPlayer]; }; 1 Share this post Link to post Share on other sites
thy_ 164 Posted September 23, 2022 On 3/3/2022 at 6:22 PM, thy_ said: Tonight I'll test on the dedicated server and later I come back with the results. Working as gold in dedicated server as well 😉 Sorry for the delay. 1 Share this post Link to post Share on other sites