Jump to content
Sign in to follow this  
killerwhale

CreateMarker issue

Recommended Posts

Hi, I'm trying to create a marker upon the detection of blufor units by opfor. the marker should be created on the "tank" units of blufor side

here is my code

Quote

marker1 = createMarker ["Marker1",nearestObjects , [unit1"Tank"], 1000]] \\\unit1 is the unit detecting the presence, once it spots the tank , this marker should be created

the problem is , i get this error code 

Quote

Error  1 element provided,3 expected

what is up with this?

Share this post


Link to post
Share on other sites
_marker= createMarker ["Marker1",((nearestObjects [position unit1, ["Tank"], 1000]) select 0)];
_marker setMarkerShape "ICON";
_marker setMarkerType "b_armor";

There is nothing about revealing targets and sides in your example.

Share this post


Link to post
Share on other sites

interesting and it works, thanks alot, what does the "select 0" mean? i dont understand that part

and if I wanted to detect if the tank is moving or stationary, how would I go about doing that?

Share this post


Link to post
Share on other sites

Because nearestObjects is returning an array of objects (it could be only one object but in array) like this

[mytankobject]

you need to select an index of this array to get the object itself.

 

[mytankobject] select 0 // mytankobject

 

I do not knew in which context you want to check object movement but you can try speed command:
 

_tank = ((nearestObjects [position unit1, ["Tank"], 1000]) select 0);

_speed = speed _tank;

if (_speed isEqualTo 0) then {

// tank is not moving

} else {

//tank is moving

};

 

Share this post


Link to post
Share on other sites

hmm, interesting, that always confounded me, now I get it, now that the speed part is fixed, the other part troubling me me now is , it just places marker on any near objects regardless of side, not quiet sure how to fix this

Share this post


Link to post
Share on other sites

help please

 

 

Quote

_tank = ((nearestObjects [position unit1, ["Tank"], 1000]) select 0);

 

 

 

how can you check the side of  "Tank"?, i want a marker created on any eastern tanks detected. problem is, it creates the marker even on western tanks

Share this post


Link to post
Share on other sites
2 hours ago, killerwhale said:

help please

how can you check the side of  "Tank"?, i want a marker created on any eastern tanks detected. problem is, it creates the marker even on western tanks

 

_tank = ((nearestObjects [position unit1, ["Tank"], 1000]) select 0);

_speed = speed _tank;

_side = side _tank;

 

if (_side == west) then

{

     //tank is west

};

 

if (_side == east) then

{

     //tank is east

};

if (_speed isEqualTo 0) then { // tank is not moving } else { //tank is moving };

Share this post


Link to post
Share on other sites

Thanks for the response but the problem still exists. the side check should take place somewhere in this code 

Quote

_tank = ((nearestObjects [position unit1, ["Tank"], 1000]) select 0);

 

 

 

reason being, the emediate thing the script does is find any vehicle nearest and sticks with it without first checking the side, 

 

so if we put 

Quote

if (_side == east) then

 

 

this only has effect on whether we should create the marker or not and has no effect on the side of the vehicle. so if the unit closest is west, and we have east unit somewhere within range, the east will never be selected,

because simply it is not the closest.

what other command can I use, nearTargets gives error findNearestEnemy i couldnt get it to work,

Share this post


Link to post
Share on other sites

Use select with expression. This will select nearest tank with WEST side and moving.

_tank = ((position _unit) nearEntities ["tank", 1000]) select { side _x == west && { _x speed > 0 } };

More info here https://community.bistudio.com/wiki/select  (alternative 5, example 6).

Better use https://community.bistudio.com/wiki/nearEntities for alive tanks (better performance)

Share this post


Link to post
Share on other sites

I was able to  use this code. provided that the unit knows about any enemies around.

 

 

Quote

_tank =((nearestObjects [player findNearestEnemy player, ["Tank"], 1000]) select 0)

 

 

it works

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  

×