# setLightDirection (Cliente)

> Cambia hacia dónde apunta una luz spot o rect.

- **Plataforma**: MY Multiplayer (MYMP)
- **Tipo**: Función Lua
- **Lado**: Cliente
- **Categoría**: Luces
- **URL**: https://wiki.mymp.gg/es/setLightDirection

## Sintaxis

```lua
bool setLightDirection(light light, float x, y, z)
```

## Parámetros

| Nombre | Tipo | Descripción |
| --- | --- | --- |
| `light` | `light` | La luz. |
| `x, y, z` | `float` | Hacia dónde apunta la luz. Tres números o un vec3, finito y no nulo; se normaliza. |

## Retorno

`true` si cambió. Con un argumento incorrecto, registra un aviso y devuelve `false`.

Mientras la luz está enganchada a otro elemento, la dirección es relativa a él. La tangente de una luz rect se rehace perpendicular a la nueva dirección.

## Ejemplo

```lua
local light = createSpotLight(2495.1, -1687.4, 20, 0, 0, -1, 25)
addEventHandler("onClientRender", root, function()
    local angle = getTickCount() / 1000
    setLightDirection(light, math.cos(angle), math.sin(angle), -1)
end)
```

### Atención

Solo para luces spot y rect. En una luz point, registra un aviso y devuelve `false`.

## Ver también

- [getLightDirection (Cliente)](https://wiki.mymp.gg/es/getLightDirection.md): Lee hacia dónde apunta una luz spot o rect.
- [setLightTangent (Cliente)](https://wiki.mymp.gg/es/setLightTangent.md): Cambia hacia dónde apunta el ancho de una luz rect, girando el rectángulo alrededor de su normal.
- [attachElements (Compartido)](https://wiki.mymp.gg/es/attachElements.md): Cuelga un elemento de otro. A partir de ahí sigue al objetivo hasta que se suelte.
