{"name":"Light Source Tutorial","title":"Light Source Tutorial","type":"topic","url":"https://community.bistudio.com/wiki/Light_Source_Tutorial","revid":370877,"updated":"2025-02-21T10:44:02Z","aliases":["Lightpoint Tutorial"],"markdown":"Armed Assault v1.00\n\n### Basics\n\nA **light source** is a non-physical object that shines a light. Its light does not cast shadows (only the sun or the moon can) and can go through walls. It can be of one of these two types:\n\n- A **light point** (glowing light source) is an all-directional light source, like a floating lightbulb, that emits light all around it.\n- A **light reflector**, much like projectors or vehicle headlights, is a beam-shaped light that was introduced in Arma 3 v2.06 (see this example below).\n\nSuch light source is **local** to the computer where the script has been called; one player could see a light in the dark while another would not have such light \"object\" created.\n\n#### Colour\n\nColour set via setLightColor determines the lens flare effect colour, as well as light's first colour.\n\n#### Ambient\n\nColour set via setLightAmbient determines the outer colour shone by the light source.\n\n> [!IMPORTANT]\n> Light colour does not affect AI spotting ability, but ambient **does**.\n\n#### Flare\n\nThe flare is the \"colour point\" centre that emits light. It can be visible or invisible (set by setLightUseFlare).\n\n> [!NOTE]\n> Flare is **not** visible by day, even using setLightDayLight.\n\n### How To\n\nThe list of all light source commands can be found in the Lights command group category.\n\n#### Create a Light Source\n\n```sqf\nprivate _lightSource = \"#lightpoint\" createVehicleLocal player modelToWorld [0, 2, 1.5];\n// alternatively, a light reflector (cone) can be created since Arma 3 v2.06\nprivate _lightSource = \"#lightreflector\" createVehicleLocal player modelToWorld [0, 2, 1.5];\n```\n\n> [!NOTE]\n> A light source is **local** (and all the light commands take a local argument too), hence createVehicleLocal's usage.\n\n#### Set Light Colour\n\n##### Colour\n\n```sqf\n_lightSource setLightColor [0.25, 1, 1]; // also defines Flare colour\n```\n\n##### Ambient Colour\n\n```sqf\n_lightSource setLightAmbient [1, 1, 1]; // sets the colour applied to the surroundings\n```\n\n#### Set Flare\n\n> [!NOTE]\n> For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour set by setLightColor must not be [0,0,0].\n\n##### Enable Flare (Arma 3 v0.50)\n\n```sqf\n_lightSource setLightUseFlare true;\n```\n\n##### Set Flare Size (Arma 3 v0.50)\n\n```sqf\n_lightSource setLightFlareSize 1; // in metre\n```\n\n##### Set Flare Visibility (Arma 3 v0.50)\n\n```sqf\n_lightSource setLightFlareMaxDistance 100; // in metre\n```\n\n#### Set Light Brightness\n\n##### Set Brightness\n\n```sqf\n_lightSource setLightBrightness 8;\n```\n\n> [!IMPORTANT]\n> Does **not** work with `#lightreflector` - use setLightIntensity instead.\n\n##### Set Intensity (Arma 3 v0.50)\n\n```sqf\n_lightSource setLightIntensity 3000;\n```\n\n##### Set Attenuation (Arma 3 v0.50)\n\n```sqf\n_lightSource setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]\n```\n\n> [!NOTE]\n> Formula is `1 / (constant + linear × dist + quadratic × dist × dist)` - see setLightAttenuation for more information.\n\n#### Make Light Visible by Day (Arma 3 v0.50)\n\n```sqf\n_lightSource setLightDayLight true; // only for the light itself, not the flare\n```\n\n#### Set IR (Arma 3 v2.06)\n\n```sqf\n_lightSource setLightIR true;\n```\n\n#### Set Reflector Angles (Arma 3 v2.06)\n\n##### Set Cone Parameters\n\n```sqf\n_lightReflector setLightConePars [90, 45, 1];\n```\n\n##### Set Reflector Volume Shape\n\n```sqf\n_lightReflector setLightVolumeShape [\"a3\\data_f\\VolumeLightFlashlight.p3d\", [1, 1, 1]];\n```\n\n#### Delete Light Source\n\n```sqf\ndeleteVehicle _lightSource; // as simple as that\n```\n\n### Examples\n\n#### Dark Souls\n\n```sqf\nskipTime -dayTime;\n\n_lightSource = \"#lightpoint\" createVehicleLocal [0,0,0];\n_lightSource attachTo [player, [0, 0, 1.5]];\n_lightSource setLightColor [0,0,0];\n_lightSource setLightAmbient [1,0.8, 0.25];\n_lightSource setLightBrightness 0.15;\n```\n\n#### Contact\n\n```sqf\nskipTime -dayTime;\n\nprivate _position = player modelToWorld [0, 20, 1.5];\nprivate _lightSource = \"#lightpoint\" createVehicleLocal _position;\n_lightSource setLightColor [0,1,1];\n_lightSource setLightAmbient [0.2,0.0,0.3];\n_lightSource setLightUseFlare true;\n_lightSource setLightFlareSize 3;\n_lightSource setLightFlareMaxDistance 3.5;\n_lightSource setLightBrightness 4;\n_lightSource setLightDayLight true;\n\n_lightSource spawn {\n    while { sleep 0.05; player distance _this > 2 } do\n    {\n        _this setLightBrightness 4 max (40 / (player distance _this));\n    };\n    deleteVehicle _this;\n};\n```\n\n#### Heli Spotlight\n\n```sqf\nprivate _reflector = \"#lightreflector\" createVehicleLocal [0, 0, 0];\n_reflector attachTo [myHeliVariable, [0, 0, 0], \"light_l\"];\n_reflector setLightColor [1, 1, 1];\n_reflector setLightAmbient [1, 1, 1];\n_reflector setLightIntensity 1e6;\n_reflector setLightConePars [60, 10, 1];\nprivate _vector3D = [[[0, 1, 0], [0, 0, 1]], 0, -45, 0] call BIS_fnc_transformVectorDirAndUp;\n_reflector setVectorDirAndUp _vector3D;\n\nprivate _light = \"#lightpoint\" createVehicleLocal [0, 0, 0];\n_light attachTo [myHeliVariable, [0, 0, 0], \"light_l\"];\n_light setLightColor [1, 1, 1];\n_light setLightAmbient [1, 1, 1];\n_light setLightUseFlare true;\n_light setLightFlareSize 5;\n_light setLightFlareMaxDistance 500;\n_light setLightBrightness 1000;\n_light setLightIntensity 10;\n```\n\n### See Also\n\n- Command Group: Lights","sections":[{"heading":null,"level":1,"markdown":"Armed Assault v1.00"},{"heading":"Basics","level":3,"markdown":"A **light source** is a non-physical object that shines a light. Its light does not cast shadows (only the sun or the moon can) and can go through walls. It can be of one of these two types:\n\n- A **light point** (glowing light source) is an all-directional light source, like a floating lightbulb, that emits light all around it.\n- A **light reflector**, much like projectors or vehicle headlights, is a beam-shaped light that was introduced in Arma 3 v2.06 (see this example below).\n\nSuch light source is **local** to the computer where the script has been called; one player could see a light in the dark while another would not have such light \"object\" created."},{"heading":"Colour","level":4,"markdown":"Colour set via setLightColor determines the lens flare effect colour, as well as light's first colour."},{"heading":"Ambient","level":4,"markdown":"Colour set via setLightAmbient determines the outer colour shone by the light source.\n\n> [!IMPORTANT]\n> Light colour does not affect AI spotting ability, but ambient **does**."},{"heading":"Flare","level":4,"markdown":"The flare is the \"colour point\" centre that emits light. It can be visible or invisible (set by setLightUseFlare).\n\n> [!NOTE]\n> Flare is **not** visible by day, even using setLightDayLight."},{"heading":"How To","level":3,"markdown":"The list of all light source commands can be found in the Lights command group category."},{"heading":"Create a Light Source","level":4,"markdown":"```sqf\nprivate _lightSource = \"#lightpoint\" createVehicleLocal player modelToWorld [0, 2, 1.5];\n// alternatively, a light reflector (cone) can be created since Arma 3 v2.06\nprivate _lightSource = \"#lightreflector\" createVehicleLocal player modelToWorld [0, 2, 1.5];\n```\n\n> [!NOTE]\n> A light source is **local** (and all the light commands take a local argument too), hence createVehicleLocal's usage."},{"heading":"Set Light Colour","level":4,"markdown":""},{"heading":"Colour","level":5,"markdown":"```sqf\n_lightSource setLightColor [0.25, 1, 1]; // also defines Flare colour\n```"},{"heading":"Ambient Colour","level":5,"markdown":"```sqf\n_lightSource setLightAmbient [1, 1, 1]; // sets the colour applied to the surroundings\n```"},{"heading":"Set Flare","level":4,"markdown":"> [!NOTE]\n> For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour set by setLightColor must not be [0,0,0]."},{"heading":"Enable Flare (Arma 3 v0.50)","level":5,"markdown":"```sqf\n_lightSource setLightUseFlare true;\n```"},{"heading":"Set Flare Size (Arma 3 v0.50)","level":5,"markdown":"```sqf\n_lightSource setLightFlareSize 1; // in metre\n```"},{"heading":"Set Flare Visibility (Arma 3 v0.50)","level":5,"markdown":"```sqf\n_lightSource setLightFlareMaxDistance 100; // in metre\n```"},{"heading":"Set Light Brightness","level":4,"markdown":""},{"heading":"Set Brightness","level":5,"markdown":"```sqf\n_lightSource setLightBrightness 8;\n```\n\n> [!IMPORTANT]\n> Does **not** work with `#lightreflector` - use setLightIntensity instead."},{"heading":"Set Intensity (Arma 3 v0.50)","level":5,"markdown":"```sqf\n_lightSource setLightIntensity 3000;\n```"},{"heading":"Set Attenuation (Arma 3 v0.50)","level":5,"markdown":"```sqf\n_lightSource setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]\n```\n\n> [!NOTE]\n> Formula is `1 / (constant + linear × dist + quadratic × dist × dist)` - see setLightAttenuation for more information."},{"heading":"Make Light Visible by Day (Arma 3 v0.50)","level":4,"markdown":"```sqf\n_lightSource setLightDayLight true; // only for the light itself, not the flare\n```"},{"heading":"Set IR (Arma 3 v2.06)","level":4,"markdown":"```sqf\n_lightSource setLightIR true;\n```"},{"heading":"Set Reflector Angles (Arma 3 v2.06)","level":4,"markdown":""},{"heading":"Set Cone Parameters","level":5,"markdown":"```sqf\n_lightReflector setLightConePars [90, 45, 1];\n```"},{"heading":"Set Reflector Volume Shape","level":5,"markdown":"```sqf\n_lightReflector setLightVolumeShape [\"a3\\data_f\\VolumeLightFlashlight.p3d\", [1, 1, 1]];\n```"},{"heading":"Delete Light Source","level":4,"markdown":"```sqf\ndeleteVehicle _lightSource; // as simple as that\n```"},{"heading":"Examples","level":3,"markdown":""},{"heading":"Dark Souls","level":4,"markdown":"```sqf\nskipTime -dayTime;\n\n_lightSource = \"#lightpoint\" createVehicleLocal [0,0,0];\n_lightSource attachTo [player, [0, 0, 1.5]];\n_lightSource setLightColor [0,0,0];\n_lightSource setLightAmbient [1,0.8, 0.25];\n_lightSource setLightBrightness 0.15;\n```"},{"heading":"Contact","level":4,"markdown":"```sqf\nskipTime -dayTime;\n\nprivate _position = player modelToWorld [0, 20, 1.5];\nprivate _lightSource = \"#lightpoint\" createVehicleLocal _position;\n_lightSource setLightColor [0,1,1];\n_lightSource setLightAmbient [0.2,0.0,0.3];\n_lightSource setLightUseFlare true;\n_lightSource setLightFlareSize 3;\n_lightSource setLightFlareMaxDistance 3.5;\n_lightSource setLightBrightness 4;\n_lightSource setLightDayLight true;\n\n_lightSource spawn {\n    while { sleep 0.05; player distance _this > 2 } do\n    {\n        _this setLightBrightness 4 max (40 / (player distance _this));\n    };\n    deleteVehicle _this;\n};\n```"},{"heading":"Heli Spotlight","level":4,"markdown":"```sqf\nprivate _reflector = \"#lightreflector\" createVehicleLocal [0, 0, 0];\n_reflector attachTo [myHeliVariable, [0, 0, 0], \"light_l\"];\n_reflector setLightColor [1, 1, 1];\n_reflector setLightAmbient [1, 1, 1];\n_reflector setLightIntensity 1e6;\n_reflector setLightConePars [60, 10, 1];\nprivate _vector3D = [[[0, 1, 0], [0, 0, 1]], 0, -45, 0] call BIS_fnc_transformVectorDirAndUp;\n_reflector setVectorDirAndUp _vector3D;\n\nprivate _light = \"#lightpoint\" createVehicleLocal [0, 0, 0];\n_light attachTo [myHeliVariable, [0, 0, 0], \"light_l\"];\n_light setLightColor [1, 1, 1];\n_light setLightAmbient [1, 1, 1];\n_light setLightUseFlare true;\n_light setLightFlareSize 5;\n_light setLightFlareMaxDistance 500;\n_light setLightBrightness 1000;\n_light setLightIntensity 10;\n```"},{"heading":"See Also","level":3,"markdown":"- Command Group: Lights"}],"categories":["ArmA: Armed Assault: Tutorials","Arma 2: Tutorials","Arma 3: Tutorials","Arma Scripting Tutorials"],"groups":["Scripting"]}