Entities
Last updated
Last updated
Entities are the core piece of any game. An entity is any object in the physical world of the game can move, interacts with physics, and more. Examples of an Entity can be anything from the character controlled by a player, a shop NPC, a vehicle, a movable block or platform, and so much more.
In short, anything that is not a permanently immovable block that makes up a world's terrain is likely best suited to be created as an entity.
Entities are highly flexible. The HYTOPIA SDK exposes the ability to fully control all aspects of an entity, including the rigid body and collider(s) representation of an entity within the game engine. The SDK will automatically assume and infer sane defaults for entities, but allows you to override any of them.
You can learn more about the Rigid Body and Colliders used to represent the physical nature of an entity here.
Entities are represented by either a GLTF (.gltf) format model from your assets
folder - we call these Model Entities. Or, by a size and block texture, we call these Block Entities.
Model Entities - Model entities are great for characters, enemies, NPCs, animals, unique terrain models that interact with the world, and much more
Block Entities - Block entities are great for moving platforms, blocks that can be push/pulled for various puzzle or terrain traversing, and more.
Here's an example of how to create and then spawn an Entity. An entity will not exist in the game until its .spawn()
method is called. An entity can be despawned at any time with .despawn()
. Once an entity is despawned, it can be respawned again with .spawn()
.
Entities are incredibly powerful and support a variety of features. We strongly recommend you check out the following guides to gain a better understanding of the different things you can do with entities.
Animations
Learn more about controlling GLTF animations for Model Entities.
Block Entities
Learn more about block entities through common use cases and examples.
Character Controllers
Learn more about character controllers to create unique movement and behaviors.
Entity Manager
Learn how to use a world's Entity Manager to iterate entities in a world.
Model Entities
Learn more about model entities and GLTF model considerations.
Movement & Pathfinding
Learn how to use the SimpleCharacterController for pathfinding, or create your own controller.
Player Controlled Entities
Learn about the PlayerEntity and using player inputs to control player entity behavior.