armatech 8 Posted October 3, 2008 Hi, I'm working on a UAV system for arma an of now we are in the final stages of the mod but would like to share how the turret works. There is currently only one know issue and its a show stopper, for some reason when you have the UAV's direction is @ any thing other then 0 degrees North then Ball will be out by the amount of the UAV's direction. if any one can help fix this issue please try out the download its just a simple UAV tracker ball. Download Share this post Link to post Share on other sites
poweruser 10 Posted October 3, 2008 replace line 28 in "ballmove.sqf" with these: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_y = ((_dir - _uavdir) * 2*pi / 360); if(_y < -pi) then { _y = _y + 2*pi; }; and use a while-do loop instead of letting the script execute itself again Share this post Link to post Share on other sites
armatech 8 Posted October 4, 2008 what is pi and its setup like this while i test <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _UAVunit = _this select 0; _target = player; _y = 0; _posA = vehicle _UAVunit modelToWorld [ 0, 5.0, -0.8 ]; _posB = getpos _target; _posAasl = getposasl _UAVunit select 2; _posBasl = getposasl _target select 2; //Elevation _distance = (_UAVunit distance _target); _x = (asin ((_posBasl - _posAasl)/_distance)); _tilt = _UAVunit animationPhase "ani_PredatorpancamX"; vehicle _UAVunit animate [ "ani_PredatorpancamX", _x]; //ROTATION _dir = ( ( _posB select 0 ) - ( _posA select 0 ) ) atan2 ( ( _posB select 1 ) - ( _posA select 1 ) ); _y = ((_dir - _uavdir) * 2*pi / 360); if(_y < -pi) then { _y = _y + 2*pi; }; vehicle _UAVunit animate [ "ani_PredatorpancamY", _y ]; //OUTPUT _rot = _UAVunit animationPhase "ani_PredatorpancamY"; //player sidechat format ["%1 X=%2 Y=%3 _rot=%4 _tilt=%5",_dir, _x, _y, _rot, _tilt]; sleep 0.01; [_UAVunit] execVM"ballmove.sqf"; Share this post Link to post Share on other sites
gsleighter 0 Posted October 4, 2008 pi is approx. 3.14159... and on and on for infinity. It's the circumference of a circle divided by the diameter. Share this post Link to post Share on other sites
poweruser 10 Posted October 4, 2008 armatech, in the code you posted now, you're missing the line which defines the local varibale _uavdir. To speed things up, here's the whole script: (i threw out the code which isnt used) <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_UAVunit","_target","_y","_x","_posA","_posB","_posAasl","_posBasl","_distance","_dir"]; _UAVunit = _this select 0; _target = player; while { alive _UAVunit } do {     // Elevation     _posAasl = getposasl _UAVunit select 2;     _posBasl = getposasl _target select 2;     _distance = (_UAVunit distance _target);     _x = (asin ((_posBasl - _posAasl) / _distance));     vehicle _UAVunit animate [ "ani_PredatorpancamX", _x];     // Rotation     _posA = vehicle _UAVunit modelToWorld [ 0,  5.0, -0.8 ];     _posB = getpos _target;     _dir = ( ( _posB select 0 ) - ( _posA select 0 ) ) atan2 ( ( _posB select 1 ) - ( _posA select 1 ) );     _y = ((_dir - (getdir _UAVunit)) * 2*pi / 360);     if(_y < -pi) then { _y = _y + 2*pi; };     vehicle _UAVunit animate ["ani_PredatorpancamY", _y];     sleep 0.01; }; Share this post Link to post Share on other sites
armatech 8 Posted October 4, 2008 armatech, in the code you posted now, you're missing the line which defines the local varibale _uavdir.To speed things up, here's the whole script: (i threw out the code which isnt used) <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_UAVunit","_target","_y","_x","_posA","_posB","_posAasl","_posBasl","_distance","_dir"]; _UAVunit = _this select 0; _target = player; while { alive _UAVunit } do {     // Elevation     _posAasl = getposasl _UAVunit select 2;     _posBasl = getposasl _target select 2;     _distance = (_UAVunit distance _target);     _x = (asin ((_posBasl - _posAasl) / _distance));     vehicle _UAVunit animate [ "ani_PredatorpancamX", _x];     // Rotation     _posA = vehicle _UAVunit modelToWorld [ 0,  5.0, -0.8 ];     _posB = getpos _target;     _dir = ( ( _posB select 0 ) - ( _posA select 0 ) ) atan2 ( ( _posB select 1 ) - ( _posA select 1 ) );     _y = ((_dir - (getdir _UAVunit)) * 2*pi / 360);     if(_y < -pi) then { _y = _y + 2*pi; };     vehicle _UAVunit animate ["ani_PredatorpancamY", _y];     sleep 0.01; }; your da man thanks a bunch ill add you to the credits of the predmod Share this post Link to post Share on other sites