hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
106 lines (49 loc) • 2.06 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [Entity](./server.entity.md) > [setParent](./server.entity.setparent.md)
## Entity.setParent() method
Sets the parent of the entity and resets this entity's position and rotation.
**Signature:**
```typescript
setParent(parent: Entity | undefined, parentNodeName?: string, position?: Vector3Like, rotation?: QuaternionLike): void;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
parent
</td><td>
[Entity](./server.entity.md) \| undefined
</td><td>
The parent entity to set, or undefined to remove from an existing parent.
</td></tr>
<tr><td>
parentNodeName
</td><td>
string
</td><td>
_(Optional)_ The name of the parent's node (if parent is a model entity) this entity will attach to.
</td></tr>
<tr><td>
position
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
_(Optional)_ The position to set for the entity. If parent is provided, this is relative to the parent's attachment point.
</td></tr>
<tr><td>
rotation
</td><td>
[QuaternionLike](./server.quaternionlike.md)
</td><td>
_(Optional)_ The rotation to set for the entity. If parent is provided, this is relative to the parent's rotation.
</td></tr>
</tbody></table>
**Returns:**
void
## Remarks
When setting the parent, all forces, torques and velocities of this entity are reset. Additionally, this entity's type will be set to `KINEMATIC_VELOCITY` if it is not already. All colliders of this entity will be disabled when parent is not undefined. If the provided parent is undefined, this entity will be removed from its parent and all colliders will be re-enabled. When setting an undefined parent to remove this entity from its parent, this entity's type will be set to the last type it was set to before being a child.