scottb613 263 Posted September 21, 2016 Hi Folks, I'm trying to manually assemble a position array after dong some math on a known position... When I look at the hint - the position appears to be in a valid format - but I don't seem to be able to use it to get a unit to move to - is there anything special in the format of a positional array? Any idea as to why the code would not work as is ? Thanks... Regards, Scott _posit = getPos s1; hint format [ "Player Position = %1",_posit ]; sleep 10; _arayX = _posit select 0; // Get player position and break down array _arayY = _posit select 1; _arayZ = _posit select 2; _arayXn = _arayX - 150; // Define new position 1 _arayYn = _arayY + 150; _targ1 = format [ "[%1,%2,%3]", _arayXn, _arayYn, _arayZ]; // Create new position array 1 hint format [ "Targ1 Position = %1",_targ1 ]; sleep 10; _arayXn = _arayX + 150; // Define new position 2 _arayYn = _arayY - 150; _targ2 = format [ "[%1,%2,%3]", _arayXn, _arayYn, _arayZ]; Sent from my iPad using Tapatalk Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 21, 2016 You could simplify this a lot: _posit = getPos s1; hint format [ "Player Position = %1",_posit ]; _targ1 = _posit; _targ2 = _posit; _targ1 vectorAdd [-150,150,0]; //position1 _targ2 vectorAdd [150,-150,0]; //position2 systemchat str format [ "Targ1 Position = %1",_targ1 ]; systemchat str format [ "Targ2 Position = %1",_targ2 ]; Why the sleeps though? AI moving towards the new positions shouldn't be an issue, what are you trying to achieve that? Cheers Share this post Link to post Share on other sites
Tajin 348 Posted September 21, 2016 _targ1 = format [ "[%1,%2,%3]", _arayXn, _arayYn, _arayZ]; // Create new position array 1 This creates a string, not an array! Positions have to be actual arrays. use this instead: _targ1 = [_arayXn, _arayYn, arayZ]; Also, using the vectormath commands is much better (like Grumpy said). Share this post Link to post Share on other sites
scottb613 263 Posted September 21, 2016 Hi Folks, Man - I owe you two a beer... This coding thing is a bit addicting - I was up until after midnight trying to get this all to work... Hah - the sleeps are to just leave the hints up on the screen long enough for me to read them while troubleshooting... I have a leg in both Arma 2 and Arma 3 - so I'm just trying to allow for backwards compatibility by only using commands that were available in Amra 2 - when I looked - vectorAdd appeared to be an Arma 3 command... I think I have it now - I'm sure you saved me countless hours of trouvpbkeshooting... :) Thanks... Regards, Scott Sent from my iPad using Tapatalk Share this post Link to post Share on other sites