You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/gdevelop5/objects/custom-objects-prefab-template/index.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Custom Objects ("prefabs")
3
3
---
4
4
# Custom Objects ("prefabs")
5
5
6
-
**Custom objects** are containers, composed of one or more other objects and having custom logic (made with events, like in a traditional scene) inside them.
6
+
**Custom objects** are containers, composed of one or more other objects and having custom logic (made with events, like in a traditional scene) inside them.
7
7
8
8
!!! tip
9
9
@@ -28,8 +28,12 @@ Custom objects are grouped into "extensions". They are composed of functions, be
28
28
29
29
To create a new custom object, the easiest way is to add a few objects on the scene, then put an instance of each on the scene editor. Select then these instances, right click/long touch the selection and choose "Extract" > **"Extract as a custom object"**.
30
30
31
+

32
+
31
33
Choose an extension name, custom object name and validate. This will open a new editor containing the objects you've selected along with the instances from the scene. In the scene, the instances you've selected are replaced by a unique custom object, that acts as a container for all of them.
32
34
35
+

36
+
33
37
!!! note
34
38
35
39
At the moment, you can't mix 2D and 3D objects in a custom object.
@@ -38,3 +42,16 @@ If you started creating events using these objects, you must rework them. Indeed
38
42
39
43
- A **doStepPostEvents** function that are events launched at every frame - much like scene events. They can do logic on the child objects. For example, it could rotate them, animate them or something else.
40
44
- One or more **action** or **condition**. If your scene wants to manipulate a child, or use a condition on it, it's a good sign that you need to "expose" this through a custom **action** or **condition**.
45
+
46
+
This is an example of a condition made inside a custom object:
47
+
48
+

49
+
50
+
Of course, this example is pretty simple and just check if the button is clicked. But similar conditions and actions could be added to manipulate the custom object, and any logic you add here will work across all the scenes using the custom object.
51
+
52
+
The condition can be then used in the scene:
53
+
54
+

55
+
56
+
57
+
By doing this for more complex needs, you can break down game menus or even gameplay objects (like a player character, complex obstacles, enemies, etc...) into custom object that can be edited independently. Your scene stays simple and only focused on the high level details of your game.
0 commit comments