Skills / Game development / Game engines: scenes, objects and scripts

Game development, lesson 2 of 8

Game engines: scenes, objects and scripts

A game engine gives you the hard parts ready-made: drawing graphics, physics, sound, input and building for different devices. The two most popular engines for independent developers are Unity, scripted in C#, and Godot, which is free and open source and scripted in GDScript (similar to Python) or C#.

Both organise a game the same basic way.

Scenes. A scene is a level, a menu or any self-contained part of the game. A game is a set of scenes the player moves between: Main menu, Level 1, Level 2, Game over.

Objects. Everything in a scene is an object: the player, an enemy, a coin, the camera, a light, an invisible zone that ends the level. Unity calls them GameObjects; Godot calls them nodes.

Components. Objects get their abilities from components attached to them:

  • A sprite or 3D model, so it can be seen
  • A collider, so it can bump into things
  • A physics body, so gravity and forces move it
  • A script, for behaviour you write yourself

Scripts. A script is your code for one kind of object. Engines call special functions for you, for example a start function once when the object appears, and an update function every frame (often 60 times a second), where you read input and move things.

Prefabs and reusable scenes. Build an enemy once, save it as a reusable template (a prefab in Unity, a saved scene in Godot), and place copies everywhere. Change the template and every copy updates.

Try it: Install Godot or Unity (both have free versions). Create a scene with one object, add a sprite to it, and press Play to run the scene.

Check yourself

1. In a game engine, what is a scene?

2. How often does an update function usually run?

3. Why use prefabs or reusable scenes?