Jump to content
Sign in to follow this  
kiberkiller

Finding unit by name?

Recommended Posts

Hello BIS forum,

I'm trying to make my first mission in ARMA 3. So far it went decently and I was able to find all the answers on the excellent wiki but I stumbled upon a problem that I can't find any solution for.

I'm making a multiplayer mission and I want to move a marker to one special OPFOR player position, every time every time BLUFOR activates a trigger.

I have figured out everything except for how to get an "object" if all I've got a the unit name, of that OPFOR player. How would I do that?

I would prefer a way to do that without external scripting, if possible.

Thanks in advance.

Share this post


Link to post
Share on other sites

I'm not sure I totally follow but if you need only one named unit to fire a trigger it would be

Opfor Present Condition box:

This and Barney in thislist
-with Barney being the name of the unit

Share this post


Link to post
Share on other sites

That's not really what I need.

I want to move a marker to UnitX's position when a trigger is activated.

How would I do that?

Share this post


Link to post
Share on other sites
"marker" setMarkerPos [(getPos Barney select 0), (getPos Barney select 1)];

Share this post


Link to post
Share on other sites
"marker" setMarkerPos [(getPos Barney select 0), (getPos Barney select 1)];

Thanks but what does "select 0" and "select 1" actually do? Why wouldn't

"marker" setMarkerPos [getPos Barney];

work?

Share this post


Link to post
Share on other sites

Markers only need x and y. Positions are arrays of x y and z. Also

"marker" setMarkerPos [getPos Barney];

Would have been incorrect anyways since you're putting an array inside of an array.

select x will select the element at index x in the array.

Also to get a unit by name

_name = "Barney";
_player = objNull;

_i = 0;
_max = count allUnits;
while { _i < _max } do
{
if(isPlayer (allUnits select _i)) then
{
	if(name (allUnits select _i) == _name) then
	{
		_player = allUnits select _i;
	};
};
_i = _i + 1;
};

if(isNull _player) then
{
//error handling
};

Edited by UNDERDAOATH

Share this post


Link to post
Share on other sites
Thanks but what does "select 0" and "select 1" actually do? Why wouldn't

"marker" setMarkerPos [getPos Barney];

work?

"marker" setMarkerPos (getPosATL barney);

the select 012 that you can specify if you want are the positions in 3d.

this comes in handy if you need a marker, like say a respawn marker to be a specific height to spawn guys on the deck of the lhd carrier instead of in the sea at ground level.

Edited by Nimrod_Z

Share this post


Link to post
Share on other sites

"marker" setMarkerPos [(getPos Barney select 0), (getPos Barney select 1)];

Explanation:

"marker" : this is the name of the marker you created on the map

setMarkerPos : this will set the position of the marker to Barney

getPos : gets the position of whatever unit/object you have specified in this case it is Barney.

select 0 or select 1 or select 2: you use the select command followed by a number to grab the index.

The index 0 of getPos is X = Length

The index 1 of getPos is Y = Depth

The index 2 of getPos is Z = Height

getPos Barney select 0 : This is getting the X coordinate of where Barney is standing

getPos Barney select 1 : This is getting the Y coordinate of where Barney is standing

"marker" setMarkerPos [(getPos Barney select 0), (getPos Barney select 1)];

This is basically saying move the marker called "marker" to the X and Y position of where Barney is standing. You will see the marker on the map.

But you dont really need all that. It doesnt matter how high a marker is if you just want to the marker to be placed at the position of a unit/object. It makes no difference. So just use this.

"marker" setMarkerPos (getPos Barney);

Since you are not specifying any indexes it will place the marker at the same X Y Z position of Barney.

This post is merely there to help explain. Not help figure out the issue at hand.

Edited by ArmASalt3

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  

×