Fortran 1 Posted August 9, 2009 For some reason I cannot get SetDir to operate using a variable in a particular part of my script, however earlier in the script before the "while" loop it works perfectly. Here is the script as it stands so far: // Plane Vars _plane = f117a; _PlaneVelocity = velocity _plane; _PlaneDirection = direction _plane; _PlaneVectorUp = vectorUp _plane; _PlaneVectorDir = vectorDir _plane; // Bomb Vars default 2 _AddSpeed = 2; // Target Vars _Target = target2; _TargetPos = getpos _Target; _TargetVectorUp = vectorUp _Target; _TargetVectorDir = vectorDir _Target; //spawn bomb and set initial velocity & vector + speed _WorldPos = _plane modeltoworld [0,0,-5]; _bomb = "GBU27_LGB" CreateVehicle _WorldPos; _bomb setDir _PlaneDirection; _bomb setVectorUp _PlaneVectorUp; _bomb setVectorDir _PlaneVectorDir; _bomb setVelocity [(_PlaneVelocity select 0)+(sin _PlaneDirection*_AddSpeed),(_PlaneVelocity select 1)+ (cos _PlaneDirection*_AddSpeed),(_PlaneVelocity select 2)]; _BombVelocity = velocity _bomb; _BombDirection = direction _bomb; _BombSpeed = speed _bomb; _BombAddSpeed = 20; sleep 1.0; while {alive _bomb} do { _BombPos = getPos _bomb; _TargetDirection = [(_TargetPos select 0) - (_BombPos select 0) atan2 (_TargetPos select 1) - (_BombPos select 1)]; _bomb setDir _TargetDirection; player sideChat format ["%1",_TargetDirection]; sleep 0.01; }; Now the line im talking about is _bomb setDir _TargetDirection; . For some reason if it is present in this codeblock then the code stops working from that point onwards. If I remove that code then it works again. I have tested without and the sideChat is spitting out the correct angle I want setDir to operate with but if the setDir line is present it just doesnt work. If I remove _TargetDirection var and replace it with a number, or even a random it works again. Anybody see what im doing wrong here? Share this post Link to post Share on other sites
UNN 0 Posted August 9, 2009 First off, make sure _TargetDirection is outputting something usable: _TargetDirection = [(_TargetPos select 0) - (_BombPos select 0) atan2 (_TargetPos select 1) - (_BombPos select 1)]; Player SideChat Format ["Dir %1",_TargetDirection]; Then perhaps try this if the above fails: _TargetDirection = [((_TargetPos select 0) - (_BombPos select 0)) atan2 ((_TargetPos select 1) - (_BombPos select 1))]; Player SideChat Format ["Dir %1",_TargetDirection]; Not actually tried it in the editor, just a suggestion. Share this post Link to post Share on other sites
Master85 1 Posted August 9, 2009 setDir needs a number, not an array _TargetDirection = (_TargetPos select 0) - (_BombPos select 0) atan2 (_TargetPos select 1) - (_BombPos select 1); Share this post Link to post Share on other sites
UNN 0 Posted August 9, 2009 From the ever helpfull Wiki Syntax: Number = x atan2 y Parameters: x: Number y: Number Return Value: Number Share this post Link to post Share on other sites
t_d 47 Posted August 9, 2009 But if you put [] around a number it gets an array ;) Share this post Link to post Share on other sites
UNN 0 Posted August 10, 2009 Doh!...didn't see that. Share this post Link to post Share on other sites
Bad Pilot 0 Posted August 10, 2009 setting facing direction on a bomb which is already dropped... what kind of effect do you expect? Share this post Link to post Share on other sites
Fortran 1 Posted August 10, 2009 (edited) Thanks very much guys, seems to be sorted now, appreciate the help. setting facing direction on a bomb which is already dropped... what kind of effect do you expect? I am attempting...or more realistically struggling, to replicate the guidance system found in the original Arma1/AII LGB's laserbombcore system. As part of the weapons system for my F117A NightHawk I have managed to replicate the sensor system of the plane to some extent and can now self designate laser targets with the mouse from the sensors switch to FLIR etc etc.. However as the DLIR sensor is mouse and dialog driven I wanted to allow the player to stay in the sensor view to both fire and monitor the payload drop as in the real plane (as seen in the F117A over Baghdad videos). As it is impossible (or so I have been led to believe) to force a laser-lock (TAB key) without physically pressing the key and I don't want to have to jump out of the sensor view and then press Tab to lock up the designated target, my only other option is to try and spawn then make the LGB's fly and track to the designated target on their own without the player having to lock it up. Unfortunately being very new to scripting its proving to be quite a headache lol. EDIT: Ok well scratch this I think, just found out the key parts I need to make it work are still working in Mando's missile suite so I will be using that instead as its infinitly better that what I would probably end up with. Edited August 10, 2009 by Fortran Share this post Link to post Share on other sites