hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
66 lines (32 loc) • 1.44 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [DefaultPlayerEntityController](./server.defaultplayerentitycontroller.md) > [attach](./server.defaultplayerentitycontroller.attach.md)
## DefaultPlayerEntityController.attach() method
Called when the controller is attached to an entity.
**Signature:**
```typescript
attach(entity: Entity): void;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
entity
</td><td>
[Entity](./server.entity.md)
</td><td>
The entity to attach the controller to.
\*\*Category:\*\* Controllers
</td></tr>
</tbody></table>
**Returns:**
void
## Remarks
\*\*Wraps `applyImpulse`<!-- -->:\*\* The entity's `applyImpulse` method is wrapped to track external velocities separately from internal movement. External impulses decay over time when grounded.
\*\*Locks rotations:\*\* Calls `entity.lockAllRotations()` to prevent physics from rotating the entity. Rotation is set explicitly by the controller based on camera orientation.
\*\*Enables CCD:\*\* Enables continuous collision detection on the entity.
\*\*Swimming detection:\*\* Registers a `BLOCK_COLLISION` listener to detect liquid blocks and manage swimming state, gravity scale, and animations.