Sertica 18 Posted March 27, 2022 I need to have a helicopter gunship move to a waypoint, then turn to face a specific direction and engage with turret without vehicle motion. I'm stuck on how to block pilot engagement flight so the gunner can fire from a static position. I tried hold waypoint with setdir in statement, but it never happens, presumably because hold waypoints never complete. Share this post Link to post Share on other sites
johnnyboy 3797 Posted March 28, 2022 For stopping the heli, you can use a Talk waypoint (which does nothing), and put this in its activation code box: this lockWp true; The helicopter will now not move to next waypoint until you unlock the waypoint like this: group heli1 lockWP false; The above assumes your helicopter is named heli1. What you are trying to do is difficult with helicopter AI. The most sure way to get the heli in the exact spot is to pre-record a heli flight and play it back based on a trigger or script when you want it to happen, using: BIS_fnc_unitCapture BIS_fnc_unitPlay Share this post Link to post Share on other sites
Sertica 18 Posted March 28, 2022 24 minutes ago, johnnyboy said: What you are trying to do is difficult with helicopter AI. The most sure way to get the heli in the exact spot is to pre-record a heli flight and play it back based on a trigger or script when you want it to happen, using: It's for a mod that makes ai drivers and gunners play like human player. All actions are run time generated, so I would have to generate the play data, which will look wonky because it is not going through physics calcs. 😬 Share this post Link to post Share on other sites
Sertica 18 Posted March 29, 2022 Code for the turn animation: #define FRAMES_PS 25 #define DEGREES_PS 60 genTurnAnim = { _targetPos = param[0,nil,[]]; _gunshipPos = getPos gunship; _gunshipDir = vectorDir gunship; _gunshipUp = vectorUp gunship; _gunshipVel = velocity gunship; // angle of turn _targetVector = _targetPos vectorDiff _gunshipPos; _vecDotProduct = [_gunshipDir select 0, _gunshipDir select 1, 0] vectorDotProduct [_targetVector select 0, _targetVector select 1]; _vecMag = vectorMagnitude _gunshipDir; _tgtVecMag = vectorMagnitude _targetVector; _vecMagProduct = _vecMag * _tgtVecMag; _turnAngleAbs = acos (_vecDotProduct / _vecMagProduct); // angular direction of turn _zCrossProduct = (_gunshipDir select 0) * (_targetVector select 1) - (_gunshipDir select 1) * (_targetVector select 0); _angDirSign = _zCrossProduct / (abs _zCrossProduct); // vec1 counter-clockwise of vec2 -> counter-clockwise direction // generate vectors _animTimeSec = (floor _turnAngleAbs) / DEGREES_PS; _frames = _animTimeSec * FRAMES_PS; _frameTimeDelta = _animTimeSec / _frames; _angPerFrame = _turnAngleAbs / _frames; _motionRecord = []; // 0:time s, 1:position, 2:dir, 3:up, 4:velocity _motionRecord resize _frames; _frameTime = 0; _angle = _angPerFrame * _angDirSign; for "_idx" from 0 to _frames-1 step 1 do { _frameArray = [nil,nil,nil,nil,nil]; // frame time _frameTime = _frameTime + _frameTimeDelta; _frameArray set[0,_frameTime]; // position _frameArray set[1,_gunshipPos]; // direction vector _frameDirX = (_gunshipDir select 0) * (cos _angle) - (_gunshipDir select 1) * (sin _angle); _frameDirY = (_gunshipDir select 0) * (sin _angle) + (_gunshipDir select 1) * (cos _angle); _frameArray set[2,[_frameDirX,_frameDirY,0]]; // up vector _frameUpX = (_gunshipUp select 0) * (cos _angle) - (_gunshipUp select 1) * (sin _angle); _frameUpY = (_gunshipUp select 0) * (sin _angle) + (_gunshipUp select 1) * (cos _angle); _frameArray set[3,[_frameUpX,_frameUpY,_gunshipUp select 2]]; // velocity vector _frameArray set[4,_gunshipVel]; _motionRecord set[_idx,_frameArray]; _angle = _angle + _angPerFrame * _angDirSign; }; _motionRecord }; Now I can put that animation in completion statement for a MOVE waypoint and test fire from static position. 2 Share this post Link to post Share on other sites
Sertica 18 Posted March 29, 2022 The returned data format is broken for unitPlay, but I have not determined what the problem is. 🤔 Quote 18:47:16 Error in expression <ityTransformation]; }; _stepProgress = linearConversion [_currentTime,_nextTime> 18:47:16 Error position: <linearConversion [_currentTime,_nextTime> 18:47:16 Error Type Any, expected Number 18:47:16 File A3\functions_f\scenes\fn_UnitPlay.sqf..., line 114 Share this post Link to post Share on other sites
Sertica 18 Posted March 30, 2022 I had to truncate the nulls out of _motionRecord. The above code now works, except the rotation amount seems to be 2x. I'll check the math and edit that post later. Share this post Link to post Share on other sites
Sertica 18 Posted March 31, 2022 This seems to prevent the pilot from moving when I reveal targets: gunshipD disableAI "TARGET"; A "MOVE" way point is fine with that set. Share this post Link to post Share on other sites