Jump to content
Sign in to follow this  
Quack O'Neill

Player distance from Unit

Recommended Posts

I need to activate a trigger when the player is a few meters away from a unit. 

this is from the wiki

_meters = player distance _object;

 
this is what i have but its not working 

3 = player distance ch2;

Anyone know why ?

Share this post


Link to post
Share on other sites
On 3/16/2022 at 1:46 AM, Quack O'Neill said:

3 = player distance ch2;

 

"The number three is equal to the distance between the player and object ch2"

In other words, if the distance is ten meters, this states that 3 = 10. I'm pretty sure that Arma won't accept this, as it would alter all math that follows within that scope.

 

"=" is an assignment operator - it assigns a value to a variable.

"==" is a comparison operator - it compares two values.

 

You want an expression that compares the distance to a set value and so evaluates as either true or false:

player distance ch2 == 3

 

Consider having a look through the first few links in my signature.

  • Like 3

Share this post


Link to post
Share on other sites

hahah lol thanks harzach for pointing that out, that will help thanks 🙂 

it didnt work but i tried this after and it working.
player distance ch2 < 3
 

Share this post


Link to post
Share on other sites
10 minutes ago, Quack O'Neill said:

it didnt work but i tried this after and it working.
player distance ch2 < 3

 

Because for the brief instant that the distance equals exactly 3, the trigger has almost no chance of evaluating it. 

 

Sorry, my example was more educational than practical.

Share this post


Link to post
Share on other sites

no your answer was great cause now i will remember this and it will help me with similar bits 🙂 thank you

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  

×