<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [PlayerCamera](./server.playercamera.md)

## PlayerCamera class

The camera for a Player.

When to use: controlling a player's view, mode, and camera offsets. Do NOT use for: moving the player or entities; use entity movement APIs.

**Signature:**

```typescript
export default class PlayerCamera extends EventRouter implements protocol.Serializable 
```
**Extends:** [EventRouter](./server.eventrouter.md)

**Implements:** protocol.Serializable

## Remarks

Access via `Player.camera`<!-- -->. Most operations require the player to be in a world.

<h2>Events</h2>

This class is an EventRouter, and instances of it emit events with payloads listed under `PlayerCameraEventPayloads`<!-- -->.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `PlayerCamera` class.

## Example


```typescript
// Camera follows player, continuously looks at enemy
player.camera.setAttachedToEntity(playerEntity);
player.camera.setTargetEntity(enemyEntity);

// Camera at fixed position, continuously looks at player
player.camera.setAttachedToPosition({ x: 0, y: 10, z: 0 });
player.camera.setTargetEntity(playerEntity);

// Stop targeting, restore manual camera control
player.camera.setTargetEntity(undefined);
```
\*\*Category:\*\* Players

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[attachedToEntity](./server.playercamera.attachedtoentity.md)


</td><td>

`readonly`


</td><td>

[Entity](./server.entity.md) \| undefined


</td><td>

The entity the camera is attached to.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[attachedToPosition](./server.playercamera.attachedtoposition.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

The position the camera is attached to.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[collidesWithBlocks](./server.playercamera.collideswithblocks.md)


</td><td>

`readonly`


</td><td>

boolean


</td><td>

Whether the camera collides with blocks instead of clipping through them.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[facingDirection](./server.playercamera.facingdirection.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md)


</td><td>

The facing direction vector of the camera based on its current orientation.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[facingQuaternion](./server.playercamera.facingquaternion.md)


</td><td>

`readonly`


</td><td>

[QuaternionLike](./server.quaternionlike.md)


</td><td>

The quaternion representing the camera's facing direction.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[filmOffset](./server.playercamera.filmoffset.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The film offset of the camera.


</td></tr>
<tr><td>

[forwardOffset](./server.playercamera.forwardoffset.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The forward offset of the camera (first-person mode only).


</td></tr>
<tr><td>

[fov](./server.playercamera.fov.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The field of view of the camera.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[mode](./server.playercamera.mode.md)


</td><td>

`readonly`


</td><td>

[PlayerCameraMode](./server.playercameramode.md)


</td><td>

The mode of the camera.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[modelHiddenNodes](./server.playercamera.modelhiddennodes.md)


</td><td>

`readonly`


</td><td>

Set&lt;string&gt;


</td><td>

Model nodes that will not be rendered for this player.


</td></tr>
<tr><td>

[modelShownNodes](./server.playercamera.modelshownnodes.md)


</td><td>

`readonly`


</td><td>

Set&lt;string&gt;


</td><td>

Model nodes that will be rendered for this player, overriding hidden nodes.


</td></tr>
<tr><td>

[offset](./server.playercamera.offset.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md)


</td><td>

The relative offset of the camera from its attachment target.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[orientation](./server.playercamera.orientation.md)


</td><td>

`readonly`


</td><td>

[PlayerCameraOrientation](./server.playercameraorientation.md)


</td><td>

The current orientation of the camera.


</td></tr>
<tr><td>

[player](./server.playercamera.player.md)


</td><td>

`readonly`


</td><td>

[Player](./server.player.md)


</td><td>

The player that the camera belongs to.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[shoulderAngle](./server.playercamera.shoulderangle.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The shoulder angle of the camera in degrees.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[targetEntity](./server.playercamera.targetentity.md)


</td><td>

`readonly`


</td><td>

[Entity](./server.entity.md) \| undefined


</td><td>

The entity the camera continuously rotates to face.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[targetPosition](./server.playercamera.targetposition.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

The position the camera continuously rotates to face.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[viewModelHiddenNodes](./server.playercamera.viewmodelhiddennodes.md)


</td><td>

`readonly`


</td><td>

Set&lt;string&gt;


</td><td>

Node substrings to hide on the view model (or attached entity's model).

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[viewModelPitchesWithCamera](./server.playercamera.viewmodelpitcheswithcamera.md)


</td><td>

`readonly`


</td><td>

boolean


</td><td>

Whether the view model pitches up/down with the camera orientation.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[viewModelShownNodes](./server.playercamera.viewmodelshownnodes.md)


</td><td>

`readonly`


</td><td>

Set&lt;string&gt;


</td><td>

Node substrings to show on the view model (or attached entity's model).

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[viewModelUri](./server.playercamera.viewmodeluri.md)


</td><td>

`readonly`


</td><td>

string \| undefined


</td><td>

The URI of the view model.


</td></tr>
<tr><td>

[viewModelYawsWithCamera](./server.playercamera.viewmodelyawswithcamera.md)


</td><td>

`readonly`


</td><td>

boolean


</td><td>

Whether the view model yaws left/right with the camera orientation.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[zoom](./server.playercamera.zoom.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The zoom of the camera.

\*\*Category:\*\* Players


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[faceEntity(entity)](./server.playercamera.faceentity.md)


</td><td>


</td><td>

Makes the camera look at an entity once.

Use for: one-off focus moments (e.g., cutscene beats). Do NOT use for: continuous tracking; use `PlayerCamera.setTrackedEntity`<!-- -->.


</td></tr>
<tr><td>

[facePosition(position)](./server.playercamera.faceposition.md)


</td><td>


</td><td>

Makes the camera look at a position once.

Use for: one-off focus moments (e.g., points of interest). Do NOT use for: continuous tracking; use `PlayerCamera.setTrackedPosition`<!-- -->.


</td></tr>
<tr><td>

[reset()](./server.playercamera.reset.md)


</td><td>


</td><td>

Resets the camera state on the server.

Use for: clearing camera state on disconnect or reconnect.


</td></tr>
<tr><td>

[setAttachedToEntity(entity)](./server.playercamera.setattachedtoentity.md)


</td><td>


</td><td>

Attaches the camera to an entity.

Use for: third-person follow cameras or entity-bound views. Do NOT use for: tracking an entity without attachment; use `PlayerCamera.setTrackedEntity`<!-- -->.


</td></tr>
<tr><td>

[setAttachedToPosition(position)](./server.playercamera.setattachedtoposition.md)


</td><td>


</td><td>

Attaches the camera to a world position.

Use for: fixed cameras or cinematic shots. Do NOT use for: tracking a moving target; use `PlayerCamera.setTrackedPosition`<!-- -->.


</td></tr>
<tr><td>

[setCollidesWithBlocks(collidesWithBlocks)](./server.playercamera.setcollideswithblocks.md)


</td><td>


</td><td>

Sets whether the camera collides with blocks instead of clipping through them.


</td></tr>
<tr><td>

[setFilmOffset(filmOffset)](./server.playercamera.setfilmoffset.md)


</td><td>


</td><td>

Sets the film offset of the camera. A positive value shifts the camera right, a negative value shifts it left.


</td></tr>
<tr><td>

[setForwardOffset(forwardOffset)](./server.playercamera.setforwardoffset.md)


</td><td>


</td><td>

Sets the forward offset of the camera (first-person mode only).


</td></tr>
<tr><td>

[setFov(fov)](./server.playercamera.setfov.md)


</td><td>


</td><td>

Sets the field of view of the camera.


</td></tr>
<tr><td>

[setMode(mode)](./server.playercamera.setmode.md)


</td><td>


</td><td>

Sets the mode of the camera.


</td></tr>
<tr><td>

[setOffset(offset)](./server.playercamera.setoffset.md)


</td><td>


</td><td>

Sets the relative offset of the camera from its attachment target.


</td></tr>
<tr><td>

[setShoulderAngle(shoulderAngle)](./server.playercamera.setshoulderangle.md)


</td><td>


</td><td>

Sets the shoulder angle of the camera in degrees (third-person mode only).


</td></tr>
<tr><td>

[setTargetEntity(entity)](./server.playercamera.settargetentity.md)


</td><td>


</td><td>

Sets the entity the camera will continuously look at.

Use for: keeping the camera focused on a moving entity.


</td></tr>
<tr><td>

[setTargetPosition(position)](./server.playercamera.settargetposition.md)


</td><td>


</td><td>

Sets the position the camera will continuously look at.

Use for: fixed focal points in the scene.


</td></tr>
<tr><td>

[setViewModel(viewModelUri)](./server.playercamera.setviewmodel.md)


</td><td>


</td><td>

Sets a view model for first-person rendering.


</td></tr>
<tr><td>

[setViewModelHiddenNodes(viewModelHiddenNodes)](./server.playercamera.setviewmodelhiddennodes.md)


</td><td>


</td><td>

Hides nodes on the view model (or attached entity's model if no view model is set).


</td></tr>
<tr><td>

[setViewModelPitchesWithCamera(viewModelPitchesWithCamera)](./server.playercamera.setviewmodelpitcheswithcamera.md)


</td><td>


</td><td>

Sets whether the view model pitches up/down with the camera orientation.


</td></tr>
<tr><td>

[setViewModelShownNodes(viewModelShownNodes)](./server.playercamera.setviewmodelshownnodes.md)


</td><td>


</td><td>

Shows nodes on the view model (or attached entity's model if no view model is set), overriding hidden nodes.


</td></tr>
<tr><td>

[setViewModelYawsWithCamera(viewModelYawsWithCamera)](./server.playercamera.setviewmodelyawswithcamera.md)


</td><td>


</td><td>

Sets whether the view model yaws left/right with the camera orientation.


</td></tr>
<tr><td>

[setZoom(zoom)](./server.playercamera.setzoom.md)


</td><td>


</td><td>

Sets the zoom of the camera.


</td></tr>
</tbody></table>
