reparent_entity
Change the parent of an entity in PlayCanvas Editor, allowing reorganization of 3D scene hierarchies while optionally preserving its transform for accurate positioning.
Instructions
Reparent an entity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | An entity ID. | |
| index | No | ||
| parent | Yes | ||
| preserveTransform | No |
Implementation Reference
- src/tools/entity.ts:50-62 (registration)MCP tool registration for 'reparent_entity', defining the input schema and a handler that forwards the request to the websocket server via wss.call('entities:reparent', options). This is the primary implementation of the MCP tool.mcp.tool( 'reparent_entity', 'Reparent an entity', { id: EntityIdSchema, parent: EntityIdSchema, index: z.number().optional(), preserveTransform: z.boolean().optional() }, (options) => { return wss.call('entities:reparent', options); } );
- extension/main.js:282-296 (handler)Core handler logic for reparenting entities using the PlayCanvas Editor API (api.entities.get and entity.reparent). Called by the MCP tool handler via websocket.wsc.method('entities:reparent', (options) => { const entity = api.entities.get(options.id); if (!entity) { return { error: 'Entity not found' }; } const parent = api.entities.get(options.parent); if (!parent) { return { error: 'Parent entity not found' }; } entity.reparent(parent, options.index, { preserveTransform: options.preserveTransform }); log(`Reparented entity(${options.id}) to entity(${options.parent})`); return { data: entity.json() }; });
- src/tools/schema/common.ts:35-35 (schema)Zod schema definition for EntityId used in the reparent_entity tool input (for both 'id' and 'parent' fields).export const EntityIdSchema = z.string().uuid().describe('An entity ID.');
- src/tools/entity.ts:53-62 (schema)Input schema for the reparent_entity tool, specifying parameters id, parent, index, and preserveTransform.{ id: EntityIdSchema, parent: EntityIdSchema, index: z.number().optional(), preserveTransform: z.boolean().optional() }, (options) => { return wss.call('entities:reparent', options); } );