Hi, I have some questions you may be able to help me with, I am an indie developer using…
- User
Hi, I have some questions you may be able to help me with, I am an indie developer using Godot.
- Assistant
Of course! I'd be happy to help with your Godot questions. What do you need assistance with?
- User
So i'm trying to make a trigger for when the player steps in a certain area, it triggers the door to ppen?
- Assistant
- User
How do I add script to the area 2d?
- Assistant
- User
I'm getting invalid character in line 7? Which is... connect(“body_entered”, self, “_on_body_entered”)
- Assistant
It looks like the issue might be with the type of quotation marks used in your script. In GDScript, you need to use straight quotes (
" ") rather than curly quotes (“ ”). Curly quotes are often introduced by word processors or certain text editors, but they are not valid in GDScript.Here's the corrected line:
connect("body_entered", self, "_on_body_entered")Make sure that all your quotation marks are straight quotes. Here is the full script again with the correct quotes:
extends Area2D export (NodePath) var door_path var door func _ready(): door = get_node(door_path) connect("body_entered", self, "_on_body_entered") func _on_body_entered(body): if body.name == "Player": # Or use `body.is_in_group("player")` door.get_node("AnimationPlayer").play("open")Just to be thorough, if you're copy-pasting between different applications, make sure to paste into a plain text editor first (like Notepad on Windows or TextEdit on macOS set to plain text mode) to remove any unwanted formatting.
If the issue persists, ensure there are no hidden characters or spaces around your code. You can do this by deleting the line and retyping it directly in the Godot editor.
- User
Line 17:Used tab character for indentation instead of space as used before in the file.
- Assistant
Godot's GDScript is very particular about indentation. It insists on either using tabs or spaces consistently throughout a script, but not both. Mixing tabs and spaces will result in errors.
To resolve the issue, you'll need to ensure that all indentation is uniform. The following script uses spaces for indentation (4 spaces per indentation level):
Here is the corrected script with consistent spacing:
extends Area2D export (NodePath) var door_path var door func _ready(): door = get_node(door_path) connect("body_entered", self, "_on_body_entered") func _on_body_entered(body): if body.name == "Player": # Or use `body.is_in_group("player")` door.get_node("AnimationPlayer").play("open") - User
Line 3:Unexpected "Identifier" in class body
- Assistant
- User
how do I add a sprite to a staticbody2d?
- Assistant