01
Overview
Tremble was my first stab at making a game engine, and I worked on it for half a year. Two other people and I started the project, and four more joined halfway through. At first the engine was aimed at FPS games.
Even though the engine is far from perfect, in the end we got some multiplayer FPS combat going. It was very interesting to see how a structure as complex as a game engine gets assembled, and it made me think about all the ways it can be done better, and how the AAA studios do it.
02
Scene graph
I made a scene graph that is integrated into everything in the engine. Objects can be parented, and all the usual transformation logic is available to the person using the engine.
03
Entity-component system
With heavy use of C++ templates, I made an entity-component system you could use much like Unity's. Components the user writes can have functions like Awake, Start and Update, and the system detects them and runs them when needed.
class PickUp : public Component {
public:
void OnTriggerEnter(const Component& other_component) {
if (other_component.GetType() == typeid(CharacterController)) {
other_component.GetNode()->FindComponent<Player>()->OnPickUp(amount, pick_up_type_);
renderable_->SetActive(false);
}
}
void Start() {
SetOnTriggerEnter(&PickUp::OnTriggerEnter, this);
// load model and set renderable
renderable_ = GetNode()->FindComponentInChildren<Renderable>();
renderable_->SetActive(true);
}
void Update() {
if (renderable_->GetActive() == false) {
if (respawn_timer_ >= respawn_time_) {
renderable_->SetActive(true);
respawn_timer_ = 0;
} else {
respawn_timer_ += Get::DeltaT();
}
}
}
Renderable* renderable_;
std::string pick_up_type_ = "Health";
float amount = 10;
float respawn_timer_ = 0;
float respawn_time_ = 2.5f;
};Pickups, written by one of my teammates with this system. Start and Update run as soon as the component is placed in the scene, with no other setup.
04
Memory management
I also made the memory management system. Different types of allocators are available to the user. Among other things, the engine itself uses a stack allocator to manage its subsystems, and pool allocators to keep components of the same type together.
05
PhysX integration
I integrated PhysX into the engine as well. It is fairly limited because of time constraints, and not all of the PhysX API is exposed, but the user can create static and dynamic objects of various shapes, including meshes, apply forces, and raycast.
06
Architecture and oversight
I did a lot of other small things to pull the engine together, such as the input system and delta time. Beyond my direct responsibilities I helped my teammates with their problems, took part in discussions about the overall structure of the engine, and did my best to make development go smoothly for everyone.