Jump to content
Sign in to follow this  
rejenorst

AI helicopter pilot to rotate helicopter?

Recommended Posts

I am trying to find a way to get a helicopter pilot to rotate in the direction of a laser target. When playing as gunner, the setting of waypoints via the move command have to be apprx 200 meters from the heli.

Any help would be appreciated. Have tried dotarget but this gives me an error.

Dowatch and lookat don't work either.

Thanks.

Share this post


Link to post
Share on other sites

I personally don't think anything will work. In any vehicle with an AI driver... being a gunner is almost impossible. That's just my opinion however.... maybe others have different ideas about it.

You can rotate the helo by using setDir.... but this is not an ideal solution.

The code below will rotate a helo. This particular code was used to rotate a helo on landing so that it points to the direction it came in to the LZ.

_dir = getDir _helo;

//turns the helo
for [{_i=0},{_i<180},{_i=_i+1}] do {
_helo setDir _dir + _i;
sleep 0.01;
};

You would have to keep applying the setDir to the helo every .x seconds to keep it pointing at the target. What this will end up looking like I have no idea.

Edited by twirly

Share this post


Link to post
Share on other sites

this works, at least for a SP mission:

place this in init line of heli:

_id = this addAction ["Rotate Right", "rotate.sqf", "right", 0, false, true, [b]"EvasiveRight"[/b], "gunner _target == _this"];
_id = this addAction ["Rotate Left", "rotate.sqf", "left", 0, false, true, [b]"EvasiveLeft"[/b], "gunner _target == _this"];

now select rotate left or right, or press the correct key once (lean (higlighted)), to start rotate that direction, once more either way stops rotating, then select same or a new to rotate.

more keys available to change for use here:

http://community.bistudio.com/wiki/ArmA_2:_CfgDefaultKeysMapping

save this as rotate.sqf

_vehicle = _this select 0;
_gunner = _this select 1;
_right = false;
if (_vehicle getVariable ["rotate", false]) then {
_vehicle setVariable ["rotate", false, true];
} else {
_vehicle setVariable ["rotate", true, true];
if ("right" == (_this select 3)) then {
	_right = true;
	_gunner groupChat "rotate right";
} else {
	_gunner groupChat "rotate left";
};
};
sleep 0.5;

while {(_vehicle getVariable ["rotate", false]) AND canMove _vehicle} do {
if (_right) then {
	_vehicle setDir ((getDir _vehicle) + 0.2);
} else {
	_vehicle setDir ((getDir _vehicle) - 0.2);
};
sleep 0.01;
if (!(_vehicle getVariable ["rotate", false])) then {_gunner groupChat "stop rotate"};
};

for some reason, i could not get vehiclechat to work so i settled for groupchat.

setFormDir only works on man units.

Share this post


Link to post
Share on other sites

Cheers will play around with some of these suggestions and see if I can get a simple N,S,SW,SE,NW,NE direction system happening. I can confirm that Setformdir only works on man units.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×