The game world consists of game objects. This basic category includes almost everything in the game, including the player, their inventory, camera, the ground under their feet, every single bush, and even the sky. Do not think that all objects must be visible – any triggers (objects that trigger events when touched), barriers, light sources, and even parts of the interface are also objects. All game objects have several basic properties: position in space (Transform), whether they are enabled (Active), what is their parent object, and whether it actually exists (Parent).
Game objects can also be supplemented with behavior (behavior or component). A behavior is a separate code that is attached to an object and executed under certain conditions. In order to understand what code knowledge you need to have, it is necessary to first choose the game engine, as all of them have different requirements. If you need help with programming, it is reasonable to address programminggeeks as they can help you with any task.
Conditions can be very different, and the number of behaviors attached to an object is unlimited. In such code, you can, for example, move the object according to the movement of the mouse or change its color. Also, each behavior can have its own separate parameters (expressed in variables).
Game Engine Possibilities
For example, we can create a “Character” behavior for a picture, which will have health points and the ability to jump. And when a character falls from somewhere, these points are taken away from them.
In addition to its own behaviors, the game engine has several standard behavior types: collision shape (Bounding Box/Sphere/Capsule/…);
- rigid body;
- particle manager;
- animator, and
- dozens of other types.
You can control all of these behaviors on the fly.
Event is a very important concept. It is a signal that occurs when certain conditions are met. The behaviors of objects in the game can trigger these events and react to them. For example, a collision is an event, and one of the most common in its use. The main gameplay is built on events, the game developer can attach the actions of some behaviors to the events of others, and so, for example, make buttons, levers, save points, and so on.
How the Game Works
There is an Update section in which you can write code and which will be executed constantly, at each game tick. A tick is the smallest unit of time that a game can provide. Usually, the tick is 16 milliseconds but if your optimization is bad, it will increase. This function is indispensable, and some things, such as smooth movement and collision checking, are written there. But the less code is written in this section, the better.
The place where game objects are located is called a level or scene. Levels can be changed at any time and in some engines, they can also be combined with each other. Your game objects will be distributed across the levels so as not to interfere with each other. For example, these will be locations and their content. But certain objects that are universal for all levels, for example, the main character or the interface, are best kept in a separate place.
Your project should have a separate folder in which you will store the saved objects (Prefab). You can construct an object in the game only once and then save it to this folder for further use. For example, it can be trees or enemies. During the game, you can create any number of objects from this folder, but it is better not to overdo it and not use thousands of objects, otherwise, the engine will start lagging.