Arma 3 Scripting

Command in Interaction

drawIcon3D

Also available as Markdown and JSON, or read the original wiki page.

Description

Draws an icon at the given position in the game world. This command has to be executed every frame. Use the Draw3D Mission Event Handler (which is executed every frame if the user can see the icon).

In order for the results of this command to be visible through a custom camera, enable HUD with cameraEffectEnableHUD.

showHUD false will hide the icon drawn by this command.

In order for arrows to appear, the icon texture should exist. The arrow size is proportionate to the icon size.

Note

  • To avoid flickering and ensure visual fidelity, always use the visual (render time scope) variant of position commands, such as getPosASLVisual.
  • The width and height parameters are multipliers for activeWidth and activeHeight set in config. So for example, if one needs to create an icon half the screen wide (safeZoneW / 2) and half the screen tall (safeZoneH / 2), divide these by the according config values:
private _iconWidth = (safeZoneW / 2) / getNumber (configFile >> "CfgInGameUI" >> "Cursor" >> "activeWidth");
private _iconHeight = (safeZoneH / 2) / getNumber (configFile >> "CfgInGameUI" >> "Cursor" >> "activeHeight");

Syntax

Syntax 1

drawIcon3D [texture, color, position, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows, offsetX, offsetY]

Parameters:

Returns: Nothing

Syntax 2

since arma3 2.22

drawIcon3D icon

Parameters:

Returns: Nothing

Examples

Example 1

Icon and text:

addMissionEventHandler ["Draw3D", {
    drawIcon3D ["targetIcon.paa", [1, 1, 1, 1], ASLToAGL getPosASLVisual cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"];
}];

Example 2

Just text:

addMissionEventHandler ["Draw3D", {
    drawIcon3D ["", [1, 0, 0, 1], ASLToAGL getPosASLVisual cursorTarget, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"];
}];

Example 3

iconPos = player getPos [10, 0] vectorAdd [0,0,2];
addMissionEventHandler ["draw3D",
{
    drawIcon3D
    [
        "\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
        [0, 0, 1, 1],
        iconPos,
        5,
        5,
        getDirVisual player,
        "COMPASS",
        0,
        0.3,
        "PuristaMedium",
        "center",
        true
    ];
}];

Example 4

Since Arma 3 v2.04

pos = player getPos [10, 0] vectorAdd [0,0,2];
addMissionEventHandler ["draw3D",
{
    _k = 10 / (player distance pos);
    drawIcon3D
    [
        "\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
        [1, 0, 0, 1],
        pos,
        1 * _k,
        1 * _k,
        0,
        name player,
        0,
        0.04 * _k,
        "RobotoCondensed",
        "right",
        true,
        0.005 * _k,
        -0.035 * _k
    ];
}];

Example 5

Since Arma 3 v2.22

removeAllMissionEventHandlers "Draw3D"; 
deleteVehicle flagA; 
flagA = createVehicle ["Flag_AAF_F", position player, [], 0, "NONE"]; 
icon = createHashMapFromArray 
[ 
    ["@position", [flagA, 5]], 
    ["@texture", "\A3\Data_F\Flags\Flag_AAF_CO.paa"], 
    ["@texts", [["Sector Alpha", 0.025, 0, 0.05, [1,1,0,1]]]], 
    ["@size", 0.05], 
    ["@drawArrows", true], 
    ["@arrowText", ["A", 0.04, 0.5, 0.3, [1,1,0,1]]],
    ["@arrowSize", 0.06], 
    ["@fade", [10, 100]], 
    ["@arrowColor", [0,1,0,1]], 
    ["@progress", [0.005, 0.05, -0.01, 0, [0.8,0.8,0,1], [0,0.6,0,0.6]]], 
    ["@progressValue", 0.67] 
]; 
addMissionEventHandler ["Draw3D", {drawIcon3D icon}];

See also

drawLine3D · getMissionPath · showHUD · cameraEffectEnableHUD

Community notes

Killzone_Kid

As command syntax indicates, this command expects icon position in format PositionAGL meaning that over the land it expects PositionATL and over the sea PositionASLW.

This command works well with addon textures, however getting it to display mission textures is a bit tricky. Follow this guide.

AgentRev

You should rely exclusively on modelToWorldVisual for a moving object's icon position if you want it to accurately stay at the correct height over the sea. It computes faster than ASLToAGL.

Width, height, and textSize are proportional to the user's interface size, which can optionally be compensated against via size / (getResolution select 5)

Additionally, width and height are inversely proportional to the fovLeft and fovTop parameters from the user's ArmaProfile, and AFAIK those parameters are not retrievable via scripting. For example, a fovTop higher than the default value of 0.75 will make all 3D icons smaller vertically. I'm not sure if this is a bug or by design, however it is definitely annoying to take into account.

DreadedEntity

drawIcon3D and BIS_fnc_addStackedEventHandler work well together.

Using formatting commands with drawIcon3D will not work, instead, they will be added to the string.

["uniqueID", "onEachFrame",
{
    drawIcon3D ["myIcon.jpg", [1,1,1,0.5], getPos player, 1, 1, 0, format ["%1\n%2", "Dreaded", "Entity"]];
}] call BIS_fnc_addStackedEventHandler;

Shown text will be Dreaded\nEntity. (A3 1.32.127785)

The "text" parameter must be a string. You cannot use Structured_Text.

["uniqueID", "onEachFrame",
{
    drawIcon3D
    [
        "myIcon.jpg",
        [1,1,1,0.5],
        getPos player,
        1,
        1,
        0,
        parseText format ["<t size='1.25' font='PuristaLight' color='#ff0000'>%1%2</t>", Dreaded, Entity]
    ];
}] call BIS_fnc_addStackedEventHandler;

(A3 1.32.127785)

Caution

This information is obsolete.

PierreMGI

If you want to use this command, on each frame, with plenty of objects or entities to mark, you can manage conditions in order to reduce the number of CPU operations. One of the most demanding CPU resource is probably a DrawIcon3D treatment for these objects/entities because even if not displayed (like for objects behind player), the CPU calculates the icons in the defined radius of your nearEntities / nearestObjects command. Don't stay with a simple radius condition (disk selecting entities or nearestObjects) which calculates all, then useless (not displayed), icons!

Here is a way to restrict this command to your screen display: in a onEachFramed context:

unitsToDisplay = allUnits;
addMissionEventHandler ["EachFrame", {
    private _offset = [0,0,0];
    {
        private _screenPosition = worldToScreen (_x modelToWorldVisual _offset);
        if (_screenPosition isEqualTo []) then { continue };
        // < your drawIcon3D treatment here >
    } foreach unitsToDisplay
}];

Tested with +100 units, equally spread on a disk. (Note: FPS depend also on environment in map. Choose a "desert" for that).