x3kj 1247 Posted June 28, 2018 Hey guys, does anybody know of a way to rotate a tank on the spot by AI commands? (not by using any setdir or similar command) I'm trying to get self propelled with limited traverse angle to work, so i need the driver to adjust orientation when gun traverse limit is reached Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted June 28, 2018 12 minutes ago, x3kj said: does anybody know Of course. Cheers 1 2 Share this post Link to post Share on other sites
x3kj 1247 Posted June 29, 2018 On 28.6.2018 at 5:36 AM, Grumpy Old Man said: Of course. Thanks, i didnt know this was possible. Pretty usefull, but unfortunately it is not accurate enough for what i'm trying to do. When i stop it rotating, it keeps going for another 70° or so (depends on physx setup). After testing i made a hybrid workaround using setDriveOnPath to a position behind the vehicle, so it starts rotating and then using doStop at the desired direction (and before it starts moving forward). This gives me reliable results of around + - 4° for the vehicles. But i'm having trouble to get it to work for AI units under player command: If i spawn the unit in eden by themself they will react to doStop commands no problem. If i spawn the unit in eden under player AI control, it reacts to doStop no problem, but only until i give the first Move Order. Then it just ignores doStop, or works very unreliably (after regroup command was ordered the first doStop works occasionally, but the second that stops it from actually going to the position in setDrivePath) handle = [] spawn { private ["_p_tar","_vehicle","_com","_speedm","_dir_rel","_drvr","_p_veh","_debug_chat","_debug"]; _p_tar = getPosASL player; //position target - where to orientate to hint format ["Pos player %1", _p_tar]; _debug_chat = true; _debug = true; _vehicle = tank; //mission object //stop vehicle from moving with group _com = effectiveCommander _vehicle; //global doStop _com; //global. Does not prevent unit from starting to move again when enemy is sighted _drvr = driver _vehicle; if (isPlayer _drvr) then { hint format ["Driver, orient %1", _dir_rel]; } else { sleep 3; //wait for it to stop _dir_tar = (_vehicle getDir _p_tar);//direction to target _dir_rel = (_dir_tar - getDir _vehicle); // _dir_rel = ((_vehicle getDir _p_tar) - getDir _vehicle); if ( abs(_dir_rel) > 4) then { if (_debug) then { diag_log [">>> ARTY FCS start traverse: rel dir to target is ",_dir_rel]; }; private _tol = 4; //stop when direction in this tolerance if ( abs(_dir_rel) > 15) then { _tol = 15 }; // increased turning distance means increased turning speed -> increase tolerance to stop earlier // calculate position behind vehicle private _clockwise=false; if (_dir_rel > 0) then { if (_dir_rel < 180) then {_clockwise=true;}; } else { if (_dir_rel <-180) then {_clockwise=true;}; }; if (abs(_dir_rel) > 120) then { if (_clockwise) then { _vehicle sendSimpleCommand "RIGHT"; } else { _vehicle sendSimpleCommand "LEFT"; }; waitUntil { _dir_rel = (_dir_tar - getDir _vehicle); if (_dir_rel > 180) then { _dir_rel = abs(360 - _dir_rel); }; if (_dir_rel < -180) then { _dir_rel = abs(_dir_rel+360); }; if (abs(_dir_rel) <= 100) exitWith {true;}; false; }; _vehicle sendSimpleCommand "STOPTURNING"; sleep 1; }; _clockwise=false; if (_dir_rel > 0) then { if (_dir_rel < 180) then {_clockwise=true;}; } else { if (_dir_rel <-180) then {_clockwise=true;}; }; private _d = 0; if (_clockwise) then { _d = (getDir _vehicle) + 150 ; hint format ["BehindVehicle Dir _d + 150 %1", _d]; } else { _d = (getDir _vehicle) - 150 ; hint format ["BehindVehicle Dir _d - 150 %1", _d]; }; _p_behind = _vehicle getPos [20,_d]; _p_veh = getPosASL _vehicle; _vehicle setDriveOnPath [_p_veh,_p_behind]; waitUntil { _dir_rel = ((_vehicle getDir _p_tar) - getDir _vehicle); if (_dir_rel > 180) then { _dir_rel = abs(360 - _dir_rel); }; if (_dir_rel < -180) then { _dir_rel = abs(_dir_rel+360); }; if (abs(_dir_rel) <= _tol) exitWith {true;}; //changing _tol tolerance makes vehicle stop earlier false; }; doStop _com; //global. Does not prevent unit from starting to move again when enemy is sighted sleep 1.5; _dir_rel = ((_vehicle getDir _p_tar) - getDir _vehicle); hint format ["relative direction final %1", _dir_rel]; }; }; }; 1 Share this post Link to post Share on other sites
thy_ 168 Posted March 5, 2023 @x3kj thanks to share it. Inspired by your code, I built a small function that just turns a tracked vehicle in the desired direction: RE-WORKING THIS CODE. I COME BACK SOON! Share this post Link to post Share on other sites