LogoLogo
  • Get Started
  • Getting Started
    • Initial Setup
    • Create Your First Game
    • API Reference
    • Build Your First World Map
    • Multiplayer Testing
    • Use Templates & Examples
    • Styling & Assets
      • Modeling Guidelines
      • Texturing Guidelines
      • Default Assets
  • Build Faster With AI Tools
  • SDK Guides
    • Assets
    • Audio & SFX
      • Audio Manager
    • Blocks & Chunks
      • Block Types
      • Block Type Registry
      • Chunks
      • Chunk Lattice
    • Camera
    • Chat & Commands
    • Debugging
    • Entities
      • Animations
      • Block Entities
      • Colliders & Hitbox
      • Child Entities
      • Entity Controllers
        • Base Entity Controller
        • Pathfinding Entity Controller
        • DefaultPlayer Entity Controller
        • Simple Entity Controller
      • Entity Manager
      • Model Entities
      • Movement & Pathfinding
      • Player Controlled Entities
    • Events
    • Input & Controls
    • Lighting
      • Ambient Light
      • Light Manager
      • Point Lights
      • Spot Lights
      • Sun Light (Directional)
    • Mobile
    • Persisted Data
    • Players
      • Player Manager
      • Persisted Player Data
    • Plugins
    • Physics
      • Colliders
      • Collision Groups
      • Debugging
      • Gravity
      • Raycasts
      • Rigid Bodies
    • User Interface
      • Overlay UI
      • Scene UIs
      • Scene UI Manager
    • Worlds
      • Map Data Format
  • Helpful Resources
    • HYTOPIA Architecture & Platform Overview
    • Useful Third-Party Tools
Powered by GitBook
On this page
  • Accessing An EntityManager
  • Using An EntityManager
  • Diving Deeper
Export as PDF
  1. SDK Guides
  2. Entities

Entity Manager

In more complex games, it's common to have many different entities spawned at the same time. This can become cumbersome to track or manage, especially if you need to do things like perform operations on specific entities.

Thankfully, we have the EntityManager that exposes ways to quickly retrieve and iterate all spawned Entities in a world.

Accessing An EntityManager

The EntityManager is used as a singleton and automatically created for a given world instance.

You can access the entity manager for a world like this:

world.entityManager

Using An EntityManager

The EntityManager exposes a number of ways to get different types of Entities for a world. Here's some examples of how you can use it.

// Returns an array of all spawned entities
// for the world
world.entityManager.getAllEntities();

// Returns an array of all spawned player
// entities for the world
world.entityManager.getAllPlayerEntities();

// Get an array of player entities currently assigned to
// the provided player. Players can have more than 1
// player entity, such as games where a player's input may
// control multiple entities at once.
world.entityManager.getPlayerEntitiesByPlayer(player)

// Get an array of entities by exact tag match
world.entityManager.getEntitiesByTag('zombie');

// Get an array of entities by tag substring match
// 'o' for example would match tags like zombie, ostritch, igloo  
world.entityManager.getEntitiesByTagSubstring('o');

Diving Deeper

PreviousSimple Entity ControllerNextModel Entities

Last updated 4 months ago

The EntityManager class is constantly evolving. You can find the latest here.

If there are features that we don't currently support for EntityManager that you'd like to see added to the HYTOPIA SDK, you can .

EntityManager API Reference
submit a feature request here