Krotox Engine › Docs › Start Here › Concepts
The mental model behind Krotox: entities and components, scenes, assets and their IDs, scripts, units, layers, and the update loop.
Five ideas explain almost everything in Krotox. Once they click, the rest of the docs read easily.
An entity is just an identity: an empty object in your scene. It does nothing and shows nothing until you give it components.
A component is a small bundle of data that gives an entity one ability:
| To get... | Add this component |
|---|---|
| a position, rotation and size | Transform2D (every entity has one) |
| a picture on screen | SpriteRenderer |
| a view of the world | Camera2D |
| physics movement | Rigidbody2D |
| a shape that collides | BoxCollider2D, CircleCollider2D, CapsuleCollider2D, PolygonCollider2D |
| a grid of tiles | Tilemap and Grid |
| buttons and HUD text | Canvas, RectTransform, UIButton, UIText |
| your own behaviour | a C# script |
A "player" is therefore not a special thing. It is an entity with a sprite, a rigidbody, a collider and a controller script. A "coin" is an entity with a sprite, a trigger collider and a pickup script. This is called an entity-component system (ECS), and Krotox uses EnTT for it.
Full list: 2D Component Reference.
A scene is one level, menu or screen: a set of entities saved to a .ktx file. A build has a start scene, marked in Build Settings, that loads first. Save with Ctrl + S.
Entities can be parented: a child moves, rotates and scales with its parent. A character's weapon is a child of the character.
Assets are the files your game uses: textures, sounds, fonts, shaders, scripts and scenes. They live in your project's Assets folder.
Each asset gets a .meta sidecar file holding a stable 64-bit ID. Scenes refer to assets by that ID, not by file name. That is why renaming or moving an asset inside the editor never breaks anything, and why you should not shuffle assets around in your file explorer.
A prefab is a saved entity you can spawn many times, for example a bullet or an enemy. In code you use Entity.Instantiate.
Gameplay is written in C#. A script is a class that inherits from Entity and declares lifecycle methods (OnCreate and OnUpdate are plain methods; the others use override):
| Method | When it runs | Typical use |
|---|---|---|
OnAwake | Once at startup, before any OnCreate | Look up components |
OnEnable | At startup, after every OnAwake | Start listening for things |
OnCreate | Once, after every OnAwake and OnEnable | Set initial state, talk to other entities |
OnUpdate(ts) | Every frame | Input, movement, game logic |
OnFixedUpdate | On a fixed 60 Hz step | Physics-related code |
OnLateUpdate | After physics and animation settle | Cameras that follow a target |
OnDisable / OnDestroy | Just before the entity is destroyed during Play | Clean up |
ts is the time in seconds since the last frame. Multiply by it to make movement independent of frame rate. Public fields on a script appear in the Inspector.
See Entity Lifecycle for the full diagram.
(0, -9.8): Y points up and gravity pulls down. For a top-down game, set the Rigidbody's GravityScale to 0.OrthographicSize is half the visible height in world units. A smaller number zooms in.Input -> OnUpdate (your scripts) -> Physics step (fixed 60 Hz, OnFixedUpdate)
-> OnLateUpdate -> Renderer batches all sprites -> Present to screen
The renderer batches sprites into as few draw calls as it can. You can watch the draw-call count and frame time in the editor's Profiler.