getPos – Talk

From Bohemia Interactive Community
Revision as of 23:20, 13 December 2013 by HeliJunkie (talk | contribs)
Jump to navigation Jump to search

Hello. There is one command missing in the list shown here and in other sites:

getVel

I have NO idea which version this came out from, but I've seen it thanks to one boy -I really can't recall where I got his script- who has done a personal bombing script. I've then tried myself to change some stuff of his and noticed this command that isn't listed in major sites! It works just like getPos; I myself still have to learn it properly, and am still far away from being good in scripts.

If anyone has more info 'bout this, PLEASE post what you know! Thanks.

I suppose velocity is what this is about? --Suma 19:33, 15 August 2006 (CEST)


Oh... I'm sorry, my bad; I'll try that out! Thanks a lot for answering Mr. Spanel. --Deusrexmachina 18:12, 17 August 2006 (CEST)

Arma 3

Altis

If I use getpos (ex. getpos player) the X and Y only has 1 digit behind the dot. If I examine the mission.sqm file, there are up to 4 digits after the dot.

Stratis

If I use getpos (ex. getpos player) the X and Y only has 2 digit behind the dot. If I examine the mission.sqm file, there are up to 4 digits after the dot.

This is very inaccurate

Anyone else has the same behaviour? If there are more with the same behaviour, I would go and open a issue @feedback.

--HeliJunkie 20:51, 10 December 2013 (CET)

This has something to do with the number format in Arma. You can only have 6 digits doesn't matter integer or float. For example 999999 is the biggest number you can have before it starts to get rounded, and -999999 is the smallest. If you go float then the smaller the number the better precision: 9.99999, 99.9999, 999.999, 9999.99, 99999.9. The unfortunate thing about this number handling is that the further away you are from the origin of the map [0,0,0] the worse the position precision.

--Killzone_Kid 13 December 2013

Hey, thanks for that hint! It has to do with formating a number to a string (not (only) with the internaly number format).

Try this code:

_num = 123456.123456789;
_num2 = 0;
if (_num >= 0) then
{
  // strip "0." after modulo (_num % 1 => 0.125)
  _num2 = [str(_num % 1), 2] call BIS_fnc_trimString;
} else
{
  // strip "-0." after modulo (for negative numbers)
  _num2 = [str(_num % 1), 3] call BIS_fnc_trimString;
};
_numString = format["%1.%2",(round _num), _num2];
hint format["Default: %1\nNumString: %2",_num, _numString];

Result should be:

Default: 123456
NumString: 123456.125

This is a little bit closer to the real number

More examples:

12345.123456789 => 12345.123047
1234.123456789  => 1234.123413
123.123456789   => 123.123459
12.123456789    => 12.123457

So of course there is already the limit of 6 digits while formating the number after the dot.

--HeliJunkie 22:19, 13 December 2013 (CET)