UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

101 lines (53 loc) 2.19 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [SimpleEntityController](./server.simpleentitycontroller.md) ## SimpleEntityController class A simple entity controller with basic movement functions. **Signature:** ```typescript export default class SimpleEntityController extends BaseEntityController ``` **Extends:** [BaseEntityController](./server.baseentitycontroller.md) ## Remarks This class implements simple movement methods that serve as a way to add realistic movement and rotational facing functionality to an entity. This is also a great base to extend for your own more complex entity controller that implements things like pathfinding. Compatible with entities that have kinematic or dynamic rigid body types. ## Example ```typescript // Create a custom entity controller for myEntity, prior to spawning it. myEntity.setController(new SimpleEntityController()); // Spawn the entity in the world. myEntity.spawn(world, { x: 53, y: 10, z: 23 }); // Move the entity at a speed of 4 blocks // per second to the coordinate (10, 1, 10). // console.log when we reach the target. myEntity.controller.move({ x: 10, y: 1, z: 10 }, 4, { moveCompleteCallback: endPosition => { console.log('Finished moving to', endPosition); }, }); ``` ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [face(target, speed, options)](./server.simpleentitycontroller.face.md) </td><td> </td><td> Rotates the entity at a given speed to face a target coordinate. </td></tr> <tr><td> [jump(height)](./server.simpleentitycontroller.jump.md) </td><td> </td><td> Applies an upwards impulse to the entity to simulate a jump, only supported for entities with dynamic rigid body types. </td></tr> <tr><td> [move(target, speed, options)](./server.simpleentitycontroller.move.md) </td><td> </td><td> Moves the entity at a given speed in a straight line to a target coordinate. </td></tr> </tbody></table>