The tick system executes game logic every frame. Classes receive time delta values and can implement update logic, movement, input handling, etc.
Architecture
The engine runs ticks in this order each frame:
- GameModule::preTick()
- All ITickable::preTick() (entities with Engine::Ecs::Tick component)
- GameModule::tick(deltaTime)
- All ITickable::tick(deltaTime) (entities with Engine::Ecs::Tick component)
- GameModule::postTick()
- All ITickable::postTick() (entities with Engine::Ecs::Tick component)
ITickable Interface
Classes that implement the tick interface inherit from Engine::Core::ITickable.
File: Engine/include/Engine/Core/Tick.h
Methods
virtual void preTick();
virtual void tick(double deltaTimeSeconds);
virtual void postTick();
All methods have empty default implementations. Override only what you need.
Example: Actor with Tick
public:
void tick(
double deltaTime)
override {
position += velocity * deltaTime;
}
};
An Actor is similar to an Engine::Entities::Entity. An actor is an Entity with a transform.
void tick(double deltaTime) override
Executed every frame.
Entity and Actor already inherit from ITickable. Override tick() directly.
Enabling Tick
Entities don't tick by default. allowTicking_ defaults to false, so set it to true before calling enableTick(true).
Scene Tick
Engine::Entities::Scene inherits from Engine::Core::ITickable, so a scene subclass can override tick(double). The active scene is not registered in the ECS tick view, so overriding Scene::tick() alone does not make it run.
Forward tick from your GameModule if you want the active scene to receive per-frame updates.
Scene Subclass
public:
}
void tick(
double deltaTimeSeconds)
override {
}
};
virtual void tick(double deltaTimeSeconds)
Function called each frame when a tick component has been registered with EnTT Ecs::Tick.
Owns scene entities, actor lifetime, and the scene graph root.
virtual void loadContent()
Loads scene content. Override in derived scenes.
GameModule Forwarding
#include "Engine/Core/Engine.h"
#include "Engine/World/SceneManager.h"
void MyGame::tick(float deltaTime) {
GameModule::tick(deltaTime);
if (engine == nullptr) {
return;
}
if (scene != nullptr) {
scene->tick(static_cast<double>(deltaTime));
}
}
const std::unique_ptr< Core::SceneManager > & getSceneManager() const
Returns the scene manager.
static EngineManager & getInstance()
Returns the singleton engine manager instance.
EngineKern * getEngineModule()
Returns the active engine.
With this wiring, MyGame::tick() calls the active scene before the engine calls tick-enabled entities. Move the scene call inside MyGame::tick() if you need game-level work before or after scene logic.
Do not call enableTick(true) on a scene. Only Entity and Actor expose enableTick() because they own an EnTT entity handle.
If a scene needs preTick() or postTick(), forward those from GameModule::preTick() and GameModule::postTick() the same way.
For Entity/Actor
public:
: Actor(context) {
allowTicking_ = true;
}
void tick(
double deltaTime)
override {
}
};
void enableTick(bool enable)
Enables or disables ticking for this entity.
Scene ownership data passed to actor and component constructors during spawning.
What enableTick Does
Adds an Engine::Ecs::Tick component to the entity's EnTT registry entry only when canEverTick() returns true:
void Entity::enableTick(bool enable) {
if (enable && canEverTick()) {
}
}
static entt::registry & get()
Gets the registry for all components.
Tick registration for objects that receive engine tick callbacks.
The engine queries all entities with Engine::Ecs::Tick each frame and calls their tick methods.
Logic Component Tick
Engine::Components::Logic doesn't inherit from ITickable but has its own tick system.
Enabling Component Tick
public:
}
void tick(
double deltaTime)
override {
}
};
Base class for all logic components that can be attached to an actor. Provides access to the scene,...
void setCanTick(bool enable)
Enables or disables ticking for this component.
virtual void tick(double deltaTime)
Called every frame if ticking is enabled.
How It Works
Actor::tick() iterates through components and calls tick() on those with ticking enabled:
void Actor::tick(double deltaTime) {
Entity::tick(deltaTime);
for (auto& component : components) {
if (component->canTick()) {
component->tick(deltaTime);
}
}
}
Non-ITickable Classes
For classes that don't inherit from ITickable, wrap them or call their update methods manually.
Option 1: Manual Calls in Actor
class ThirdPartySystem {
public:
void update(float dt) { }
};
ThirdPartySystem system_;
public:
void tick(
double deltaTime)
override {
system_.update(static_cast<float>(deltaTime));
}
};
Option 2: Wrap in Logic
class ThirdPartySystem {
public:
void update(float dt) { }
};
ThirdPartySystem system_;
public:
}
void tick(
double deltaTime)
override {
system_.update(static_cast<float>(deltaTime));
}
};
actor->addComponent<ThirdPartySystemComponent>(scene);
GameModule Tick
Override GameModule methods for global game logic.
File: Engine/include/Engine/Game/GameModule.h
public:
}
void tick(
float deltaTime)
override {
gameTime_ += deltaTime;
}
}
};
Base interface implemented by game-specific engine modules.
virtual void preTick()
Runs logic before the game tick.
virtual void postTick()
Runs logic after the game tick.
virtual void tick(double deltaTime)
Runs per-frame game logic.
Async Tick (Asset Pipelines)
Asset pipelines use tick() for state machine advancement, not frame timing.
Example: Engine::Ecs::ModelAssetPipeline::tick(bool async)
void tick(bool async = true) {
submitLoadModel(async);
processModel(async);
processMaterial(async);
processMeshData(async);
}
These ticks happen each frame but advance background loading tasks. The async parameter controls whether work happens on background threads or the main thread.
Delta Time
Delta time is the seconds elapsed since the last frame.
Get delta time:
double dt = EngineManager::getInstance().getEngineModule()->getDeltaTimeSeconds();
Typical usage:
void tick(double deltaTime) {
position += direction * 5.0f * static_cast<float>(deltaTime);
rotation += 90.0f * static_cast<float>(deltaTime);
}
Checking Tick State
if (entity->canTick()) { }
if (entity->canEverTick()) { }
if (component->canTick()) { }
Summary
| Class Type | Inherits ITickable? | How to Enable | Tick Method |
| Entity/Actor | Yes | enableTick(true) | Override tick() |
| Logic component | No | setCanTick(true) | Override tick() |
| GameModule | No | Always ticks | Override tick() |
| Scene | Yes | Forward active scene tick from GameModule | Override tick() |
| Other classes | No | Wrap in component or call manually | N/A |
Default execution order: GameModule → Entities (with Engine::Ecs::Tick) → Components (within their entity)
Scene forwarding order: GameModule → Scene (where you call it) → Entities (with Engine::Ecs::Tick) → Components (within their entity)
Files:
- Engine/include/Engine/Core/Tick.h - ITickable interface
- Engine/include/Engine/Entity/Entity.h - Entity tick
- Engine/include/Engine/Component/LogicComponent.h - Component tick
- Engine/src/Engine/Core/Engine.cpp - Main loop tick execution
- Engine/include/Engine/Ecs/EcsData.h - Engine::Ecs::Tick component definition