[**SixL client API**](../../README.md)

***

[SixL client API](../../README.md) / [cameras](../README.md) / CameraMp

# Interface: CameraMp

A script camera: a camera the script makes and moves; it is shown on screen when it is active and rendering is on.

## Remarks

The game makes the camera on the next frame. Calls made before that wait for it and run in the order they were made.
The getters return the values last set. The camera is removed when the client leaves the server.

## Example

```ts
const cam = mp.cameras.new('default', { x: 0, y: 0, z: 80 }, { x: -20, y: 0, z: 90 }, 50);
```

## Properties

### handle

> `readonly` **handle**: `number`

The game's handle of the camera; `0` until the game has made it on the next frame.

#### Remarks

Read only: the game sets it when the camera is made.

#### Example

```ts
const handle = cam.handle;
```

## Methods

### attachTo()

#### Call Signature

> **attachTo**(`entity`, `xOffset`, `yOffset`, `zOffset`, `isRelative`): `void`

Attaches the camera to an entity at an offset, so it moves with it.

##### Parameters

###### entity

[`GameEntity`](../../game/common/type-aliases/GameEntity.md)

The entity.

###### xOffset

`number`

The offset's x.

###### yOffset

`number`

The offset's y.

###### zOffset

`number`

The offset's z.

###### isRelative

`boolean`

True: the offset turns with the entity.

##### Returns

`void`

##### Remarks

Partial: not yet confirmed in the game. RAGE MP's other form (the 14 arguments of an entity's attachTo) takes its position as the offset, relative.

##### Example

```ts
cam.attachTo(mp.players.local, 0, -4, 2, true);
```

#### Call Signature

> **attachTo**(`entity`, `boneIndex`, `xPos`, `yPos`, `zPos`, `xRot`, `yRot`, `zRot`, `p8`, `useSoftPinning`, `collision`, `isPed`, `vertexIndex`, `fixedRot`): `void`

Attaches the camera to an entity, in the form of an entity's attachTo: the position is the offset, relative.

##### Parameters

###### entity

[`GameEntity`](../../game/common/type-aliases/GameEntity.md)

The entity.

###### boneIndex

`number`

Not used.

###### xPos

`number`

The offset's x.

###### yPos

`number`

The offset's y.

###### zPos

`number`

The offset's z.

###### xRot

`number`

Not used.

###### yRot

`number`

Not used.

###### zRot

`number`

Not used.

###### p8

`boolean`

Not used.

###### useSoftPinning

`boolean`

Not used.

###### collision

`boolean`

Not used.

###### isPed

`boolean`

Not used.

###### vertexIndex

`number`

Not used.

###### fixedRot

`boolean`

Not used.

##### Returns

`void`

##### Remarks

Partial: not yet confirmed in the game; only the position is used.

##### Example

```ts
cam.attachTo(vehicle, 0, 0, -6, 2, 0, 0, 0, false, false, false, false, 2, true);
```

***

### attachToPedBone()

> **attachToPedBone**(`ped`, `boneIndex`, `x`, `y`, `z`, `heading`): `void`

Attaches the camera to a bone of a ped at an offset.

#### Parameters

##### ped

[`GameEntity`](../../game/common/type-aliases/GameEntity.md)

The ped.

##### boneIndex

`number`

The bone, as the game numbers it.

##### x

`number`

The offset's x.

##### y

`number`

The offset's y.

##### z

`number`

The offset's z.

##### heading

`boolean`

True: the camera turns with the ped.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.attachToPedBone(mp.players.local, 0, 0, 0.5, 0.6, true);
```

***

### destroy()

> **destroy**(`destroy?`): `void`

Removes the camera. Its calls queued meanwhile are dropped.

#### Parameters

##### destroy?

`boolean`

Accepted for RAGE MP compatibility; ignored.

#### Returns

`void`

#### Remarks

After this the camera no longer exists (see [CameraMp.doesExist](#doesexist)) and the pool no longer holds it.

#### Example

```ts
cam.destroy();
```

***

### detach()

> **detach**(): `void`

Detaches the camera from the entity it is attached to.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.detach();
```

***

### doesExist()

> **doesExist**(): `boolean`

Whether the camera still exists: it was not destroyed.

#### Returns

`boolean`

`true` until [CameraMp.destroy](#destroy) is called, and `false` after.

#### Example

```ts
if (cam.doesExist()) { }
```

***

### getCoord()

> **getCoord**(): [`Vector3`](../../common/interfaces/Vector3.md)

The camera's position.

#### Returns

[`Vector3`](../../common/interfaces/Vector3.md)

The position last set with [CameraMp.setCoord](#setcoord) (or at creation), in metres.

#### Remarks

Returns what was set: the game does not answer for it.

#### Example

```ts
const pos = cam.getCoord();
```

***

### getDirection()

> **getDirection**(): [`Vector3`](../../common/interfaces/Vector3.md)

The direction the camera looks along, as a unit vector.

#### Returns

[`Vector3`](../../common/interfaces/Vector3.md)

The direction, from the rotation last set (0 yaw is north, +y).

#### Remarks

Computed from the rotation set by the script; an attached or pointing camera may look elsewhere.

#### Example

```ts
const dir = cam.getDirection();
```

***

### getFov()

> **getFov**(): `number`

The camera's vertical field of view.

#### Returns

`number`

The field of view last set with [CameraMp.setFov](#setfov) (or at creation), in degrees.

#### Remarks

Returns what was set: the game does not answer for it.

#### Example

```ts
const fov = cam.getFov();
```

***

### getRot()

> **getRot**(`rotationOrder?`): [`Vector3`](../../common/interfaces/Vector3.md)

The camera's rotation.

#### Parameters

##### rotationOrder?

`number`

Accepted for RAGE MP compatibility; ignored.

#### Returns

[`Vector3`](../../common/interfaces/Vector3.md)

The rotation last set with [CameraMp.setRot](#setrot), in degrees: `x` the pitch (positive looks up), `y` the
roll, `z` the yaw (0 is north, 90 is west).

#### Remarks

Returns what was set: the game does not answer for it.

#### Example

```ts
const rot = cam.getRot(2);
```

***

### isActive()

> **isActive**(): `boolean`

Whether the camera is the active one.

#### Returns

`boolean`

The value last set with [CameraMp.setActive](#setactive): `false` once the camera is destroyed.

#### Remarks

Returns what was set: the game does not answer for it.

#### Example

```ts
if (cam.isActive()) { }
```

***

### isInterpolating()

> **isInterpolating**(): `Promise`\<`boolean`\>

Whether the camera is still moving to where setActiveWithInterp or setParams sent it.

#### Returns

`Promise`\<`boolean`\>

A Promise of true while it moves.

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
const moving = await cam.isInterpolating();
```

***

### isRendering()

> **isRendering**(): `boolean`

Whether the camera is on screen: it is active and rendering of script cameras is on.

#### Returns

`boolean`

`true` when the game draws this camera; `false` before it is made or after it is destroyed.

#### Example

```ts
const onScreen = cam.isRendering();
```

***

### isShaking()

> **isShaking**(): `Promise`\<`boolean`\>

Whether the camera shakes.

#### Returns

`Promise`\<`boolean`\>

A Promise of true while it shakes.

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
const shaking = await cam.isShaking();
```

***

### pointAt()

> **pointAt**(`entity`, `offsetX?`, `offsetY?`, `offsetZ?`, `p4?`): `void`

Makes the camera keep looking at an entity.

#### Parameters

##### entity

[`GameEntity`](../../game/common/type-aliases/GameEntity.md)

The entity to look at: an entity object, or its handle.

##### offsetX?

`number`

Accepted for RAGE MP compatibility; ignored: the camera looks at the entity itself.

##### offsetY?

`number`

Accepted for RAGE MP compatibility; ignored.

##### offsetZ?

`number`

Accepted for RAGE MP compatibility; ignored.

##### p4?

`boolean`

Accepted for RAGE MP compatibility; ignored.

#### Returns

`void`

#### Example

```ts
cam.pointAt(player);
```

***

### pointAtCoord()

> **pointAtCoord**(`x`, `y`, `z`): `void`

Makes the camera keep looking at a point.

#### Parameters

##### x

`number`

The x position of the point in metres.

##### y

`number`

The y position of the point in metres.

##### z

`number`

The z position of the point in metres.

#### Returns

`void`

#### Example

```ts
cam.pointAtCoord(0, 0, 75);
```

***

### pointAtPedBone()

> **pointAtPedBone**(`ped`, `boneIndex?`, `x?`, `y?`, `z?`, `heading?`): `void`

Makes the camera keep looking at a ped.

#### Parameters

##### ped

[`GameEntity`](../../game/common/type-aliases/GameEntity.md)

The ped to look at: an entity object, or its handle.

##### boneIndex?

`number`

Accepted for RAGE MP compatibility; ignored: the camera looks at the ped as a whole.

##### x?

`number`

Accepted for RAGE MP compatibility; ignored.

##### y?

`number`

Accepted for RAGE MP compatibility; ignored.

##### z?

`number`

Accepted for RAGE MP compatibility; ignored.

##### heading?

`boolean`

Accepted for RAGE MP compatibility; ignored.

#### Returns

`void`

#### Example

```ts
cam.pointAtPedBone(ped, 0, 0, 0, 0, false);
```

***

### setActive()

> **setActive**(`active`): `void`

Makes the camera the active one, or not. It is shown on screen after [GameCamMp.renderScriptCams](../../game/cam/interfaces/GameCamMp.md#renderscriptcams) turns
rendering on.

#### Parameters

##### active

`boolean`

`true` to make it the active camera.

#### Returns

`void`

#### Example

```ts
cam.setActive(true);
```

***

### setActiveWithInterp()

> **setActiveWithInterp**(`camFrom`, `duration`, `easeLocation`, `easeRotation`): `void`

Makes this camera the active one, moving to it smoothly from another camera.

#### Parameters

##### camFrom

`number` \| `CameraMp`

The camera to move from (or its handle).

##### duration

`number`

Milliseconds.

##### easeLocation

`number`

How the position eases, as the game numbers it.

##### easeRotation

`number`

How the rotation eases, as the game numbers it.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.setActiveWithInterp(otherCam, 2000, 1, 1);
```

***

### setCoord()

> **setCoord**(`posX`, `posY`, `posZ`): `void`

Sets the camera's position.

#### Parameters

##### posX

`number`

The x position in metres.

##### posY

`number`

The y position in metres.

##### posZ

`number`

The z position in metres (up).

#### Returns

`void`

#### Example

```ts
cam.setCoord(0, 0, 80);
```

***

### setFarClip()

> **setFarClip**(`farClip`): `void`

Sets the distance from the camera at which the picture ends.

#### Parameters

##### farClip

`number`

The distance in metres.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.setFarClip(1000);
```

***

### setFov()

> **setFov**(`fieldOfView`): `void`

Sets the camera's vertical field of view.

#### Parameters

##### fieldOfView

`number`

The field of view in degrees (50 is the usual view).

#### Returns

`void`

#### Example

```ts
cam.setFov(60);
```

***

### setMotionBlurStrength()

> **setMotionBlurStrength**(`strength`): `void`

Sets how much the picture blurs when the camera moves.

#### Parameters

##### strength

`number`

The strength, from 0.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.setMotionBlurStrength(0.5);
```

***

### setNearClip()

> **setNearClip**(`nearClip`): `void`

Sets the distance from the camera at which the picture starts.

#### Parameters

##### nearClip

`number`

The distance in metres.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.setNearClip(0.1);
```

***

### setParams()

> **setParams**(`x`, `y`, `z`, `xRot`, `yRot`, `zRot`, `fov`, `duration`, `graphTypePos`, `graphTypeRot`, `rotOrder`): `void`

Sets the position, rotation and field of view at once, moving there over a time.

#### Parameters

##### x

`number`

The position's x.

##### y

`number`

The position's y.

##### z

`number`

The position's z.

##### xRot

`number`

The pitch, degrees.

##### yRot

`number`

The roll, degrees.

##### zRot

`number`

The yaw, degrees.

##### fov

`number`

The field of view, degrees.

##### duration

`number`

Milliseconds (0: at once).

##### graphTypePos

`number`

How the position eases, as the game numbers it.

##### graphTypeRot

`number`

How the rotation eases, as the game numbers it.

##### rotOrder

`number`

The rotation order.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game. getCoord, getRot and getFov return the new values.

#### Example

```ts
cam.setParams(0, 0, 80, -20, 0, 90, 50, 1000, 1, 1, 2);
```

***

### setRot()

> **setRot**(`rotX`, `rotY`, `rotZ`, `rotationOrder?`): `void`

Sets the camera's rotation.

#### Parameters

##### rotX

`number`

The pitch in degrees (positive looks up).

##### rotY

`number`

The roll in degrees.

##### rotZ

`number`

The yaw in degrees (0 is north, 90 is west; counter-clockwise from north).

##### rotationOrder?

`number`

Accepted for RAGE MP compatibility; ignored.

#### Returns

`void`

#### Example

```ts
cam.setRot(-20, 0, 90);
```

***

### shake()

> **shake**(`type`, `amplitude`): `void`

Shakes the camera with a named shake.

#### Parameters

##### type

`string`

The shake's name (or its hash).

##### amplitude

`number`

The strength, from 0.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game. The shake names are the game's own.

#### Example

```ts
cam.shake('<shake name>', 0.5);
```

***

### stopPointing()

> **stopPointing**(): `void`

Stops the camera looking at a point or an entity.

#### Returns

`void`

#### Example

```ts
cam.stopPointing();
```

***

### stopShaking()

> **stopShaking**(`stopImmediately`): `void`

Stops the camera's shake.

#### Parameters

##### stopImmediately

`boolean`

True to stop at once, false to let it fade.

#### Returns

`void`

#### Remarks

Partial: not yet confirmed in the game.

#### Example

```ts
cam.stopShaking(true);
```
