Jump to content
Sign in to follow this  
Wetherby

Problem with Player distance

Recommended Posts

Hello everyone,

I have a problem in my Arma mission, i want to spawn ennemi only if the distance between player and marker is less than the axis A plus 250 meters, i have search a lot and i have tried this command :

_mark = _this select 0;

_markaxisA = getMarkerSize _mark select 0;

_calcul = _markaxisA + 250;

_target = _calcul;

waitUntil {(_mark distance player) <= _target};

but it does't work so I request your big knowledge about script

Thank for your time and attention

Share this post


Link to post
Share on other sites

Well, break it down. What "doesn't work"? Do you have -showscripterrors enabled? Are you receiving errors? How are you executing it? What does _this select 0 reference?

It's difficult for us to help you if you only say "it doesn't work" and do not provide us the information to take a holistic approach.

To start you off, make sure your first line of _this select 0 is actually referring to something, meaning a passed array. But for my example I'm going to guess it is not.

_mark = "nameofmarkerhere";
_marksize = getMarkerSize _mark;
_markaxisA = _marksize select 0; 
_target = _markaxisA + 250;

waitUntil {(_mark distance player) <= _target};

Share this post


Link to post
Share on other sites

Sorry, _this select 0 is refering to a trigger(No condition and no activation so is work) with an execVM with the marker array, i have trie a hint to say where is error and error is on player distance and i have no script error.

Thank for your correction

I have tried to indicate the name of marker like your script correction but it doesn't work always.

Share this post


Link to post
Share on other sites

Sorry, wasn't thinking about the string. You can only judge distance from objects, and a marker is not an object. So you'll need to create a game logic or some object that represents the same position as the center of the marker. Or, just use the array from the return of getMarkerPos, which I've done.

_mark = "testmkr";
_marksize = getMarkerSize _mark;
_markaxisA = _marksize select 0; 
_target = _markaxisA + 250;
_markpos = getMarkerPos _mark;

waitUntil {(_markpos distance player) <= _target};

So, this works, however it isn't as you had expected, since it works from the marker's center. So I suggest you rely on a point, like the script. However, if you are doing this in a way that it works, go for it.

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  

×