Skip to content

Commit 17d74b8

Browse files
authored
Merge pull request #230 from AadityanAnbumani/updates-for-making-interactable-objects-in-godot
added character creation section and a few clarity fixes
2 parents 03f4bcd + 26a5ca7 commit 17d74b8

8 files changed

Lines changed: 45 additions & 9 deletions

File tree

‎projects/add-interactable-objects-to-your-godot-game/add-interactable-objects-to-your-godot-game.mdx‎

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Your project is now ready! Click "2D" at the top center of the editor, because w
6363

6464
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/Godot2DprojectScreen.png" />
6565

66-
Now right-click on the resources folder in the bottom left and then click on "Create New" → "Folder...":
66+
Now right-click on the Resources folder in the bottom left and then click on "Create New" → "Folder...":
6767

6868
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/folderCreationGodot.png" />
6969

@@ -77,7 +77,7 @@ Now add a node component and name it whatever you like (you can do this by doubl
7777

7878
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/addNode2.png" />
7979

80-
Create a new folder inside the resources folder and name it **scenes**.
80+
Create a new folder inside the Resources folder and name it **scenes**.
8181

8282
Now press <kbd>ctrl</kbd> + <kbd>s</kbd> on your keyboard to bring up the Save menu and click on the **scenes** folder, then "Save" to save your new scene to the **scenes** folder.
8383

@@ -86,22 +86,26 @@ Now press <kbd>ctrl</kbd> + <kbd>s</kbd> on your keyboard to bring up the Save m
8686
Now we have all the groundwork set up, your file manager in the bottom left should look something like:
8787

8888
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/fileSystemGodot.png" />
89-
Now drag and drop the **Background.png** file into the editor screen:
89+
Now we'll setup the game's environment, drag and drop the **Background.png** file into the editor screen:
9090

9191
<video width="100%" controls>
9292
<source src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/backgroundImageAddition.mp4" type="video/mp4" />
9393
Your browser does not support the video tag.
9494
</video>
9595

96-
We can do the same thing with the rest of the assets, you can even drag in the same asset multiple times, and it’ll be numbered accordingly. Here’s mine; try to get yours somewhat similar, as it will make it easier to follow along:
96+
We can do the same thing with the rest of the assets and build a simple room like I've shown in the video below.
97+
98+
{/* mapBuilding.mp4 */}
99+
100+
If you encounter an issue where you can't see the item you placed, make sure that it is either below or attached to the background image. Below is the room I made, but as long as you have some items in your room like in the video above, you should be good!
97101

98102
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/sceneSetup.png" />
99103

100-
Make sure to also drag in the asset called “E”, next to each of the objects you have placed. Make sure to drag the Es under the object you are placing them next to in the left panel, Here’s how I have it setup:
104+
Make sure to also drag in the asset called “E”, next to each of the objects you have placed. Make sure each E is a child of the object it belongs to in the Scene panel, Here’s how I have it setup:
101105

102106
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/ESetup.png" />
103107

104-
Now, we also need to add labels for the text that will appear when we interact with an object. Click on an object in the left panel, then press <kbd>ctrl</kbd> + <kbd>a</kbd>, search for “label” and add it. Now click on your new label node, and in its right panel you should see a box to type text. Add whatever text you want to see when you interact with that object, and move the text on top of the black bar.
108+
Now, we also need to add labels for the text that will appear when we interact with an object. Click on an object in the left panel, then press <kbd>Ctrl</kbd> + <kbd>A</kbd> (Add Child Node), search for “label” and add it. Now click on your new label node, and in its right panel you should see a box to type text. Add whatever text you want to see when you interact with that object, and move the text on top of the black bar.
105109

106110
It should look something like this:
107111

@@ -115,6 +119,36 @@ Make sure to add a label for the other objects, so you can have different text f
115119

116120
<ImageZoom src="https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/add-interactable-objects-to-your-godot-game/assets/EAndLabelVisibility.png" />
117121

122+
## Character creation
123+
124+
Before I move on to collision shapes, I will quickly go over making a simple character in Godot.
125+
126+
First make a new scene by clicking the plus icon near the tabs at the top.
127+
128+
{/* addingNewScene.png */}
129+
130+
Now press <kbd>Ctrl</kbd> + <kbd>A</kbd> and search for CharacterBody2D and select it.
131+
132+
{/* addCharacterBody2D.png */}
133+
134+
Now click on the CharacterBody2D you added in the left panel, and add a CollisionShape2D and a Sprite2D to it. They will appear as child nodes to the character body as shown below.
135+
136+
{/* charHierarchy.png */}
137+
138+
With that done, follow the video below to setup the collision shape and sprite for your character. The image I'm using for the character sprite is **boyGhostSingle.png**.
139+
140+
{/* characterMaking.mp4 */}
141+
142+
Now the last thing we need to do is add a movement script to the character. Click the button shown below.
143+
144+
{/* scriptAttach */}
145+
146+
Then make sure that the basic movement script is selected, then press create.
147+
148+
{/* moveScript */}
149+
150+
Now save it to the scenes folder, and name it "blobGhostPlayer" as it will be easy to follow along when we get to the code section.
151+
118152
With that set up, you can watch [this video](https://www.youtube.com/watch?v=3M3olvGE-EI) to set up a simple character in Godot, you can use the **boyGhostSingle.png** file for the texture. Make sure to save your character into the scenes folder.
119153

120154
Drag your character in like you have been doing for everything else, and bam, we’re done setting up the project. Now let’s move on to adding our interactive feature!
@@ -254,8 +288,8 @@ func _process(delta: float) -> void: //_process() runs every frame
254288
```
255289

256290
Now we are checking for two new conditions:
257-
- If the player is inside an `Area2D` using the player_inside variable that we have been turning on and off
258-
- The "interact" keyboard input
291+
- Whether the player is inside the Area2D (tracked using the player_inside variable)
292+
- Whether the player presses the interact action
259293

260294
Now, when I walk into an object's `Area2D` and press E, I see a description about that object in the game!
261295

@@ -282,4 +316,6 @@ Thanks for following along, and I can’t wait to see the interactions you creat
282316

283317
### More Resources
284318

285-
-
319+
- If you want to learn more about the cool stuff Area2D can do check out [this link](https://docs.godotengine.org/en/stable/classes/class_area2d.html)
320+
- Here's a [short video](https://www.youtube.com/watch?v=3M3olvGE-EI) on character creation if you have trouble with any part of it
321+
- The Github for Before I fade, the game this tutorial is based on is [here](https://github.com/vishyyyyyyyyy/before-i-fade), feel free to use the assets and try out your own mods and changes to practice your new skills
274 KB
Loading
229 KB
Loading
20.4 KB
Loading
Binary file not shown.
Binary file not shown.
270 KB
Loading
203 KB
Loading

0 commit comments

Comments
 (0)