Skip to content

Commit 017d130

Browse files
authored
Add more details to custom object docs
1 parent 085554c commit 017d130

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed
336 KB
Loading
506 KB
Loading
507 KB
Loading
646 KB
Loading

docs/gdevelop5/objects/custom-objects-prefab-template.md renamed to docs/gdevelop5/objects/custom-objects-prefab-template/index.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Custom Objects ("prefabs")
33
---
44
# Custom Objects ("prefabs")
55

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.
77

88
!!! tip
99

@@ -28,8 +28,12 @@ Custom objects are grouped into "extensions". They are composed of functions, be
2828

2929
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"**.
3030

31+
![Two objects extracted into a single custom object](./extract-custom-object.png)
32+
3133
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.
3234

35+
![A custom object that was just created](./custom-object-with-two-buttons.png)
36+
3337
!!! note
3438

3539
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
3842

3943
- 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.
4044
- 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+
![A custom condition in a custom object](./custom-condition-in-custom-object.png)
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+
![](./condition-used-from-custom-object.png)
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

Comments
 (0)