From ce0d2f283ff19136a28cee376a8b8e43f03dfe60 Mon Sep 17 00:00:00 2001 From: Aadityan Anbumani Date: Tue, 21 Jul 2026 09:55:04 -0500 Subject: [PATCH] Fixed code indentation and missing image --- ...nteractable-objects-to-your-godot-game.mdx | 22 +++++++++--------- ...ctInGodot.png => createProjectInGodot.png} | Bin 2 files changed, 11 insertions(+), 11 deletions(-) rename projects/add-interactable-objects-to-your-godot-game/assets/{creatProjectInGodot.png => createProjectInGodot.png} (100%) diff --git a/projects/add-interactable-objects-to-your-godot-game/add-interactable-objects-to-your-godot-game.mdx b/projects/add-interactable-objects-to-your-godot-game/add-interactable-objects-to-your-godot-game.mdx index 48ebe034..33f0082c 100644 --- a/projects/add-interactable-objects-to-your-godot-game/add-interactable-objects-to-your-godot-game.mdx +++ b/projects/add-interactable-objects-to-your-godot-game/add-interactable-objects-to-your-godot-game.mdx @@ -188,8 +188,8 @@ func _ready(): //runs ONCE at the start of a scene func _on_body_entered(body): if body.name == "blobGhostPlayer": - player_inside = true - $"../E".visible = true + player_inside = true + $"../E".visible = true ``` The ```_on_body_entered``` function receives a signal when a body enters that `Area2D` node’s collision shape and triggers the code inside the function. @@ -207,22 +207,22 @@ Isn’t that cool? With just a few lines of code, you can set up an interaction ```python func _on_body_exited(body): if body.name == "blobGhostPlayer": - player_inside = false - $"../E".visible = false + player_inside = false + $"../E".visible = false ``` This function is very similar to the ```_on_body_entered()``` from earlier, except now it's checking if the player exited the `Area2D`. If it does, then the ```player_inside``` variable gets set to false, and the E image hides. Moving onto the final bit of code. This is where things get interesting. Instead of triggering an event solely by detecting if the character walked into an `Area2D`, we add another level of interaction requiring the character to press a key while standing in the area. -``` +```python func _process(delta: float) -> void: //_process() runs every frame - if player_inside and Input.is_action_pressed("interact"): - print("interact pressed on area") - $"../Label".visible=true - $"../../Box2/Label".visible=false - $"../../Box7/Label".visible=false - $"../../Bloodblanket/Label".visible=false + if player_inside and Input.is_action_pressed("interact"): + print("interact pressed on area") + $"../Label".visible=true + $"../../Box2/Label".visible=false + $"../../Box7/Label".visible=false + $"../../Bloodblanket/Label".visible=false ``` Now we are checking for two new conditions: diff --git a/projects/add-interactable-objects-to-your-godot-game/assets/creatProjectInGodot.png b/projects/add-interactable-objects-to-your-godot-game/assets/createProjectInGodot.png similarity index 100% rename from projects/add-interactable-objects-to-your-godot-game/assets/creatProjectInGodot.png rename to projects/add-interactable-objects-to-your-godot-game/assets/createProjectInGodot.png