# llSetCameraParams

*LSL function*

Replaces deprecated `llTakeCamera`.

```lsl
void llSetCameraParams(list rules);
```

- `list rules`: A strided list of rules and data pairs configuring the camera.

- Energy: 10
- Permission: `PERMISSION_CONTROL_CAMERA`

Sets multiple camera parameters simultaneously using the list of rules. Requires the PERMISSION_CONTROL_CAMERA runtime permission.

Sets multiple camera parameters at once.

```lsl title="How to use" frame="terminal"
llSetCameraParams([]);
```

## Specification

Constant group [CameraParam](/constants/groups/CameraParam/):

```lsl
CAMERA_ACTIVE, integer isActive
CAMERA_BEHINDNESS_ANGLE, float degrees
CAMERA_BEHINDNESS_LAG, float seconds
CAMERA_DISTANCE, float meters
CAMERA_FOCUS, vector position
CAMERA_FOCUS_LAG, float seconds
CAMERA_FOCUS_LOCKED, integer isLocked
CAMERA_FOCUS_OFFSET, vector meters
CAMERA_FOCUS_THRESHOLD, float meters
CAMERA_PITCH, float degrees
CAMERA_POSITION, vector position
CAMERA_POSITION_LAG, float seconds
CAMERA_POSITION_LOCKED, integer isLocked
CAMERA_POSITION_THRESHOLD, float meters
```

## Caveats

- Camera control currently (server 1.38) only supported for attachments and objects on which you are sitting. An attempt otherwise will result in an error being shouted on [DEBUG_CHANNEL](/constants/DEBUG_CHANNEL/).
- Scripted camera parameters are overriden for agents who are in [Free Camera mode](https://wiki.secondlife.com/wiki/Flycam) *(Alt + Click)*. **No error is returned if this is the case**; however when the agent returns to regular camera mode, their camera will go to the scripted camera position.
- When [CAMERA_FOCUS](/constants/CAMERA_FOCUS/) is not defined, it is advised that [CAMERA_FOCUS_THRESHOLD](/constants/CAMERA_FOCUS_THRESHOLD/) is set to 0.0 - this is because when left at it's default value, it may prevent the camera from focusing on the correct point, instead focusing just to the side of the intended point.
- A [CAMERA_FOCUS_OFFSET](/constants/CAMERA_FOCUS_OFFSET/) of [ZERO_VECTOR](/constants/ZERO_VECTOR/) will always look at the same position as returned by `llGetPos()` for the avatar
- When seated, this is also the position of "Avatar Center" when hover height is 0
- When standing, this has a shape-dependent z-offset from "Avatar Center". (currently investigating [Tapple Gao](https://wiki.secondlife.com/wiki/User:Tapple_Gao) ([talk](https://wiki.secondlife.com/wiki/User_talk:Tapple_Gao)))
- Cannot be used to control the camera in Mouselook.

## Examples

<details open>
<summary>You can either set the camera in region relative coordinates or you can make the camera follow your avatar.</summary>

**Region relative coordinates, an example:**

```lsl collapse={1-5}
lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        vector camPos = llGetPos() + (relCamP * llGetRot() * turnOnChair) ;
        vector camFocus = llGetPos() ;
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_FOCUS, camFocus, // region relative position
            CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
            CAMERA_POSITION, camPos, // region relative position
            CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)
        ]);
    }
}
```

</details>

<details>
<summary>Note that Focus and Position are both locked. This first example makes the camera look at *camFocus* from *camPos*.</summary>

**Camera follow avatar, an example:**

```lsl
lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_BEHINDNESS_ANGLE, 30.0, // (0 to 180) degrees
            CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
            CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
          //CAMERA_FOCUS, <0,0,5>, // region relative position
            CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
            CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
            CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
            CAMERA_PITCH, 10.0, // (-45 to 80) degrees
          //CAMERA_POSITION, <0,0,0>, // region relative position
            CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
            CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
            CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
            CAMERA_FOCUS_OFFSET, <2.0, 0.0, 0.0> // <-10,-10,-10> to <10,10,10> meters
        ]);
    }
}
```

</details>

Note that in this second example Focus and Position are NOT locked and not even set. This is appropriate for making the camera follow a pilot on a vehicle.

## Tests

- [llSetCameraParams Test](https://wiki.secondlife.com/wiki/llSetCameraParams_Test)

## Known issues

From the issue templates included by the wiki article:

- SCR-325 (nf): Damping Parameters for llSetCameraParams()
- SCR-326 (nf): &lt;code>CAMERA_FOCUS_TARGET&lt;/code> and &lt;code>CAMERA_POSITION_TARGET&lt;/code> parameters for llSetCameraParams()
- SCR-327 (meta): Improvements to llSetCameraParams()

## See also

### Functions

- [llClearCameraParams](/functions/llClearCameraParams/)
- [llGetCameraPos](/functions/llGetCameraPos/)
- [llGetCameraRot](/functions/llGetCameraRot/)
- [llSetLinkCamera](/functions/llSetLinkCamera/)
- [llSetCameraEyeOffset](/functions/llSetCameraEyeOffset/)
- [llSetCameraAtOffset](/functions/llSetCameraAtOffset/)

### Articles

- [FollowCam](https://wiki.secondlife.com/wiki/FollowCam)

---

*Source: [LlSetCameraParams](https://wiki.secondlife.com/wiki/LlSetCameraParams) on the Second Life Wiki. Content from the Second Life Wiki articles LlSetCameraParams (revision 1217653, 2024-11-16), Template:Issues/SCR-325 (revision 1167116, 2012-05-12), Template:Issues/SCR-326 (revision 1167135, 2012-05-12), Template:Issues/SCR-327 (revision 1167136, 2012-05-12) and Template:LSL Function/permission (revision 1200093, 2016-05-12), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llSetCameraParams/
