Overview
Entities are the core game objects in Hyperscape. Every player, mob, item, and resource is an Entity with 3D representation, networking, physics, and component-based functionality.Entity Hierarchy
Key Features
Frompackages/shared/src/entities/Entity.ts:
Entity Class
Lifecycle Methods
Component Management
Default Components
Every entity automatically gets these components:Network Synchronization
Health and Damage
Position and Transform
PlayerEntity
The player entity extends CombatantEntity with player-specific features:Player Components
The stamina system is affected by both weight (inventory load) and agility level. Heavier loads increase stamina drain, while higher agility increases regeneration.
MobEntity
Mob entities represent hostile NPCs with AI behavior:Events
Entities can emit and listen to events:Best Practices
- Use components for data - Don’t add properties directly to entities
- Check component existence - Always null-check
getComponent()results - Mark network dirty - Call
markNetworkDirty()after state changes - Override lifecycle methods - Implement
createMesh(),onInit(),onInteract()in subclasses - Clean up properly - Override
destroy()and callsuper.destroy()