Skip to content

Commit fa6e044

Browse files
Update layered portrait documentation (#60)
1 parent f3be56e commit fa6e044

15 files changed

+41
-123
lines changed

documentation/layered-portraits.md

Lines changed: 41 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,87 @@
1-
2-
31
<div class="header-banner pineapple">
42
<div class="header-label pineapple">Layered Portraits</div>
53
</div>
64

7-
*This page describes how to create layered portraits.*
5+
*This page describes how to create and use layered portrait scenes.*
86

97
## 📜 Content
8+
109
[toc]
1110

1211
## 1. Introduction
1312

14-
If you want to have a character with multiple layers, like a body, a head, and
15-
a mouth, you can use the **Layered Portrait** feature.
16-
17-
Dialogic uses the concept of Godot scenes to create portraits. The layered portrait feature provides us with a GDScript that you can use for this purpose.
18-
19-
If you are eager to learn more about the requirements for creating a custom portrait, please refer to the [Custom Portraits](custom-portraits.md) page.
13+
If you want to have a character with multiple layers, like a body, a head, and a mouth, you can use the custom **Layered Portrait** scene. This scene allows creating a character from many sprites and then allows showing, hiding and switching between these sprites **from the timeline!**
2014

15+
If you are eager to learn more about how dialogic uses scenes to create portraits and the requirements for creating a custom portrait, please refer to the [Custom Portraits](custom-portraits.md) page.
2116

2217
## 2. Rundown
2318

24-
You will learn to create a new character, add a new portrait, and then create a
25-
new Godot scene for the custom scene of this portrait.\
26-
Finally, you will learn how to control the layers of the portrait using the
27-
timeline.
19+
First, you will learn how to create a new layered portrait scene and set it up correctly.
2820

21+
Finally, you will learn how to control the layers of the portrait using the timeline.
2922

3023
## 2.1. Preparation
3124

32-
I will use a character named `Agustina`, if you want to follow along, you can download the assets from [https://dejinyucu.itch.io/agustina-visual-novel-sprite](https://dejinyucu.itch.io/agustina-visual-novel-sprite).\
33-
Heads up: The character is available as a PSD file; you will have to pick the
34-
layers and export them as image files.
35-
36-
37-
## 3. Creating a new Character
38-
39-
First, head over to the Dialogic Character tab. You will need to create
40-
yourself a new character or edit an existing one.
41-
42-
Each character can have multiple portraits. You can add a new portrait or use
43-
an existing one.
44-
45-
Heading over to the last segment of the Character Editor, you will find the
46-
preview and the **Portrait Settings**.\
47-
Unfold the **Scene** option, and you will see a file picker. We will head back
48-
here once the scene file is done, set it.
49-
50-
![Character Editor: Scene Picker](media/layered_portrait/portrait_settings_scene_empty.png)
51-
52-
53-
## 4. Creating a Portrait Scene
54-
55-
Now, we want to create a new scene in the **FileSystem** tab of Godot.
56-
We recommend creating a new folder for your portrait scenes, so you can keep
57-
your project organized.
58-
59-
Right-click on the folder and hover **Create New**, and click **Scene...** on the
60-
follow-up menu.
25+
I will use a character named `Agustina`, if you want to follow along, you can download the assets from [https://dejinyucu.itch.io/agustina-visual-novel-sprite](https://dejinyucu.itch.io/agustina-visual-novel-sprite).
6126

62-
Select the **Root Type**, we recommend using the **Node** option, selecting the
63-
`CanvasGroup` type.
27+
*Heads up: The character is available as a PSD file; you will have to pick the layers and export them as image files.*
6428

65-
The `CanvasGroup` type allows Godot to treat all layers as a single image,
66-
preventing the layers from fading in and out separately.
29+
You will also have to have a character. You can use an existing one or create a new one for this. On that character (in the Character Editor) add or select a portrait.
6730

68-
The **Scene Name** is up to you, but once again, we recommend keeping your
69-
project organized with a consistent naming scheme.
31+
## 3. Creating the Base Layered Portrait Scene
7032

71-
![Creating a new scene](media/layered_portrait/create_scene.png)
33+
In the Character Editors "Portrait Settings" section, head to the **Scene** section.
7234

73-
Once you press **OK**, your new scene will be opened in the **Scene** tab of
74-
Godot. Switch to the **2D** tab in the upper-middle of Godot, and you will see
75-
your new scene.
35+
![Portrait Setting Scene Empty](media/layered_portrait/portrait_setting_scene_empty.jpg)
7636

77-
![Layered Scene: Empty](media/layered_portrait/layered_scene_empty.png)
37+
Click the little arrows icon to change the portrait scene.
7838

79-
## 4.1. Adding the Layered Portrait GDScript
39+
In the popup that opens select the `Layered Portrait` and then click `Customize This Scene`.
8040

81-
To use your scene as a layered portrait, we will add a built-in
82-
GDScript to the root node of your scene.
41+
![Custom Portrait Selection Popup](media/layered_portrait/custom_portrait_selection_popup.jpg)
8342

84-
Right-click on the root node and hover over **Attach Script**.
43+
This will promt you to save the new scene somewhere in the file system. Navigate to a place that makes sense in your file oranization and adjust the file name if necessary. Then click `Save`.
8544

86-
![Layered Scene: Attach Script](media/layered_portrait/layered_scene_attach_script.png)
45+
You can now open this scene with the little arrow icon button (or from the file system).
8746

88-
You can copy the following path and paste it into the **Path** field:
47+
![Portrait Setting Scene Set](media/layered_portrait/portrait_setting_scene_set.jpg)
8948

90-
```
91-
res://addons/dialogic/Modules/Character/LayeredPortrait/layered_portrait.gd
92-
```
93-
94-
![Attach Node Script](media/layered_portrait/attach_node_script_window.png)
95-
96-
Press **Load** and... that's it! You have now added the Layered Portrait
97-
scripting logic; now onto the fun part!
98-
99-
```admonish info
100-
The script may open in the **Script** tab of Godot or an external editor,
101-
feel free to ignore this and move back to the **2D** tab.\
102-
It's not recommended to edit this file without copying it to your own project's
103-
folder.
104-
```
105-
106-
## 4.2. Adding the Layers
107-
108-
Your layered portrait can have multiple layers. We recommend using `Node2D` as
109-
grouping layers, and `Sprite2D` as the actual layers.
49+
## 4. Filling the scene
11050

111-
There is no limitation what Node Types you use for your layers.
51+
At the beginning the scene will have only a few nodes to get you started:
11252

113-
This will require some manual work, but it gives you control over how the
114-
layers are organized. The node paths will be used in the
115-
**Layer Command Syntax**; we will cover this in a later section.
53+
![](media/layered_portrait/scene_empty.jpg)
11654

55+
You will usually have a "Base" layer, which should be the first Sprite we add. So we select the first Sprite, rename it to "Base", and drag our base texture into the inspectors `Texture` property.
11756

118-
Here is my scene structure:
57+
For anything you have "variations" of, in this case for example the Eyes, Eyebrows, Mouths and Clothes, you'll want to have a "Group", like the one that is already in the scene. A group will later allow us to easily switch between these variations.
11958

120-
![Layered Scene: Complete](media/layered_portrait/layered_scene_complete.png)
59+
By adding more Groups (Node2D) and Sprites (Sprite2D), naming them properly (we will use these later) and setting the textures, we will get something like this:
12160

122-
I left some of the layers hidden to define the default look of the portrait.
61+
![](media/layered_portrait/scene_final.jpg)
12362

124-
## 4.3. Setting the Layered Portrait Scene
63+
*Note: The Sprites of the Augustina example all fill the same rectangle. This means they are automatically all correctly positioned on top of each other. If your sprites cover different regions of the character, you might have to manually move them to be positioned correctly.*
12564

126-
Remember the file picker in the Character editor? Now is the time to use it!
127-
Copy the path of your scene file and paste it into the file picker or navigate
128-
to your scene file.
12965

130-
![Scene Picker: Layered Portrait](media/layered_portrait/portrait_settings_scene_set.png)
13166

132-
Once you have selected your scene file, you should be able to see your portrait
133-
in the Character Editor's Preview.
67+
Save the scene and head back to the character editor. If everything went right, you should now see your scene there:
13468

69+
![](media/layered_portrait/finished_portrait_in_editor.jpg)
13570

136-
## 5. Controlling the Layers
71+
Hurray!
13772

138-
As of right now, you can use the `Character` event to control the layers.
139-
The functionality is limited to the `join` and `update` variants of this event.
73+
## 5. Controlling the Layers from the timeline
14074

141-
In Dialogic, this event accepts a parameter called `extra_data`. Using the Layer
142-
Command Syntax, you can control the portraits from timelines using the
143-
`extra_data`.
75+
You can control these layers from the character event (when joining or updating). Any communication with the portrait scene happens via the `extra_data` parameter, for example like this:
14476

145-
Take a look at this example:
14677
```tml
147-
join agustina (Layered) 2 [animation="Heartbeat" extra_data="set Mouth/Smile"]
78+
join Agustina center [extra_data="set Mouth/Happy"]
79+
[wait_input]
80+
update Agustina [extra_data="set Eyes/Wink, set Mouth/Laugh, set Clothes/Outfit2"]
14881
```
14982

83+
In the visual editor you can use the same commands in the "Extra Data" field.
84+
15085
## 5.1. Layer Command Syntax
15186

15287
Here is a list of valid commands you can use in the `extra_data` parameter:
@@ -177,29 +112,12 @@ update agustina [extra_data="show Glasses/Normal, set Emote/Shock"]
177112

178113
# 6. FAQ
179114

180-
## 6.1. My Portrait is hovering above the Scene Ground
181-
182-
Make sure all of your layers have the correct size.
183-
184-
The Layered Portrait will use the size of all layers combined. If one layer is
185-
extending further down than the others, it may appear floating above the ground
186-
if the layer is not enabled.
187-
188-
Try enabling all of your layers and select all nodes, you will be able to see
189-
all boundaries in the editor window of your scene.
190-
191-
192-
## 6.2 My Portrait's Position is heavily off
193-
194-
If you use a `Control` (and comparable types), ensure that its position aligns
195-
with the root's position. Otherwise, the overall coverage of your portrait
196-
will be visually unpredictable in the editor.
115+
## 6.1. My Portrait's Position is wrong
197116

117+
The layered portrait calculate the combined size of all the layers. If your layers have different sizes/positions, make sure no layer extends further then needed. Try enabling all of your layers and select all nodes, you will be able to see all boundaries in the editor window of your scene.
198118

199-
## 6.3 Do I have to use `CanvasGroup` as Root Node?
119+
By default the Layered Portraits scripts `fix_offset` parameter (in the inspector under Layered Portrait/Private/fix_offset) is on. This will adjust the position based on the first sprite on the assumption that it will be the base sprite. For many portraits that makes it easier, but for more granular control you can turn it off. In that case your sprites should be positioned so that the top-left corner of your character is at the scene origin!
200120

201-
No, but if you use any transitions on your layered sprite, the player will see
202-
every single layer fading at once.
121+
## 6.2 Do I have to use `CanvasGroup` as Root Node?
203122

204-
If you have a Skin Layer covered mostly by a Dress Layer, you will see the Skin
205-
and Dress layer fading in and out separately.
123+
No, but it's the best at handling transitions.
-21.2 KB
Binary file not shown.
-29.9 KB
Binary file not shown.
108 KB
Loading
45.5 KB
Loading
Binary file not shown.
-26 KB
Binary file not shown.
-7.53 KB
Binary file not shown.
8.72 KB
Loading
7.31 KB
Loading

0 commit comments

Comments
 (0)