Common features to all objects

In a GDevelop game, everything on the screen is an object.

Add an object to the game

In a scene, we can add objects by simply clicking the add object button on the right, on the bottom of the objects list:

You can choose from many different type of objects, all with specific properties and purpose:

Depending on what type of object you have chosen, the editor, aspect of the object and the available features in the events will be different. As the goal of this page is to explain objects in general, we won't go in to details of these unique properties on each type. You can find detailed information on each type of object here.

Objects in the scene

Add an instance on the scene

An object can be positioned on the scene by selecting the object in the Object tab (click/tap on it) and then click in the scene to put an instance of that object. An instance is basically a copy of the object living on the scene. Each instance has its own variables, position, animations (for sprite objects), content (for texts), etc…

We can change the position of an object by selecting the object in the scene editor and drag it. We can scale the object by selecting the object and drag one of the white scale points

Modifying properties

When we select an object in the scene editor, the properties panel on the left shows information about the selected instance(s). If it is not open, you can re-open it by clicking the properties button in the toolbar:

Position

You can precisely set the position of the selected instances by changing the X and Y values in the properties:

Angle

You can set the angle of the instance(s) by changing the angle value:

The angle can be any value from 0 to 360 degrees. Remember this diagram to see what is the orientation of a given angle:

Z order

You can change the Z order of an instance in the properties:

The purpose of the Z order is to allow to specify which object will be displayed first, when instances are overlapping. More precisly, we can control if the object is behind an other object or it is in front by setting different values: when two objects are overlapping, the object with the lower value of Z order will be displayed behind the other.

Values can be any integer, including negative numbers and 0.

On the above image the Z order of the bush on left is 2, the Z order of the coin is 1 and the Z order of the bush on the right is 0.

Layer

You can set the layer of an instance:

By default, each GDevelop scene comes with a single layer called the “Base layer”. This is where all objects are located in our scene. We can add more layers for various purposes and put any instance on any layer. For example, there can be a layer to display controls on screen, another to display a menu, a map, or a background.

Lock position/angle

By ticking the box “Lock position/angle in the editor”, you can make the instance immovable in the editor:

When the instance is locked, we can not longer select it in the scene. There are times when you have lot of objects overlapping each other in your scene. This makes it difficult to select some of them as we keep selecting the ones we don't intend to. In such cases, you can lock the instances.

You can unlock a locked instance by opening the instances panel, which is displaying all the instances in our scene and select the object from the list.

Instance variables

The “edit variables” button allows to specify variables that are specific to the selected instance:
A variable is basically a container that is holding a value (a number, a text), which can be compared and modified during the game. There are different type of variables in GDevelop, in particular each object can contain variables. When the game is running, each instance of the object living on the scene will have its own variables.

The “Edit variables” allow you to specify variables that are specific to the selected instance. For example, if you have objects representing boxes with gold on the scene, you can modify the variable named “Gold” of each instance to set a different number. Then in the events, when the player collides with a box, you can read the variable value to add it to the player gold amount.

Custom size

You can change the size of your objects, by enabling the custom size in the properties panel, and then enter the custom width and height dimensions in pixels:

Object groups

An object group is a set of objects. For example, a group called “Enemies” can contain the object “Mushroom”, “Bomb”, “Dinosaur”. You can then use the name of the group in the events to refer to all the objects contained in the group.

This makes possible to create events that applies to lots of objects without repeating events multiple times, increasing performance of your game, maintainability and readability of your events.

To open the Groups Editor, click the groups icon on the toolbar:

In the Groups Editor are listed all the groups of the scene (and global groups too, which are available in all scenes of the game). To add a group click on the button on the bottom of the list:

A new group is added to the lost:

  • To change the name of the group, right click on the group and select Rename.
  • To add objects to the group, tap or click the group.

In the window that open to edit the group, click on the bottom field and choose an object (or type the name of an object) to add it to the group.

Variables

Each object can contain variables, which are memory cells that you can use to store information. When the game is running, each instance of the object living on the scene will have its own variables.

Read this page to learn more about variables.

Timers

Objects can hold their own timers, and each timer will be unique for each instance of the object living on the scene. Object timers are useful to make instances to launch actions after/every X seconds.

For example, a classic usage is to simulate shooting bullets. If you have a single tank on the scene, you could use a scene timer so that every 3 seconds, this tank can fire (create a bullet) and then reset the timer (so the tank can shoot again).

The issue is that if you have 2 tanks and use a scene timer you'll notice both tanks shoot at the same time, because they are sharing the same scene timer. You need to have two separate timers, independent from each other, to make the second tank to shoot at its own rate. But what if you have 100 tanks? You don't want to create 100 scene timers, one per instance.

This is when object timers are getting useful: replace every condition/action using the scene timer with the conditions/actions to use object timers. During the game, GDevelop will create a timer inside each tank instance. When you will be using a condition to check the value of a timer, only the instance that have a timer that have a value in seconds that is greater to the number you've entered will be picked.

You can read more about timers here: Timers

In the events editor

You can change and manipulate the properties of an instance of an object, or of multiple instances, using events during the game. This is even what game making is all about in GDevelop: to manipulate objects in real-time as we play the game. As the events and events editor are out of the scope of this page, refer to the basic game making concepts page to get started.

  • All objects share the same common features (like position, angle and everything that is written on this page), and there are a lot of conditions and actions that you can use for all objects.
  • Objects can also provides you with specific feature. For example, Sprite objects can have animations, and the animation being played can be changed using an action.