Skip to content

Light Object Guide

Peter Robinson edited this page Jun 24, 2026 · 2 revisions

Introduction

The LightObject dynamically draws a color at a location and radiates it outward. Collision objects cast shadows in the light as they pass through it. Because a LightObject is also a SceneObject, it can move, rotate, and even fade using all the same methods that a SceneObject uses — however, the size of the LightObject is controlled internally by the light radius, not by the usual Size field.

The light's color comes from the object's blend color — the BlendColor field (setBlendColor()), inherited from SceneObject. Give it a yellow blend color, for example, and the light radiates yellow. See the Blending guide for more on blend color and alpha.

TorqueScript Bindings

Exposed Fields

The LightObject type exposes the following fields in addition to those it inherits from SceneObject. Shown are the equivalent methods available that perform the same action in setting and getting the respective field:

  • LightRadius — The distance that the light travels before disappearing, in world units.
  • setLightRadius(float)
  • getLightRadius()
  • LightSegments — The number of segments used to draw the light. More segments look smoother but take more processing power.
  • setLightSegments(int)
  • getLightSegments()

Example

Creating a light in script:

%light = new LightObject();
%light.LightRadius = 20;
%light.LightSegments = 32;
%light.BlendColor = "1 1 0 1";   // radiate yellow (BlendColor is inherited from SceneObject)
%light.setPosition("0 0");

// add it to your scene
%scene.add(%light);

The same object saved as TAML:

<LightObject
    Position="0 0"
    BlendColor="1 1 0 1"
    LightRadius="20"
    LightSegments="32" />

Clone this wiki locally