Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Mac ShortcutsedmunditoI noticed that in the godot documentation as well as this page that the shortcut to open the 2D editor is "Alt+1" but I believe that may be a linux shortcut. For mac, the default is Ctrl+Command+number (1 is 2D, 3 is script editor)13Feb. 25, 2024
Refactor using "Make Scene Root"iDieIn this case, wouldn't it be more efficient to add the Area2D node and use the option "Make Scene Root" on it?
This way, we wouldn't lose the Sprite2D properties.23Feb. 19, 2024
How to play a sound and freeing the queue?DefumakHello, after finished the lesson 3, I started to play around by adding a sound when touching a HealthPack node. It works, but I'm not sure if it's the best approach. I need to hide the image and disable the CollisionShape2D, in order to play the sound, then, call queue_free only after finishing the sound. Otherwise, queue_free will destroy the entire node and stop the player before finishing the audio.
Would be possible to detach the AudioStreamPlayer node?, so I can free the node without waiting for the sound finish. But I'm not sure about managing the Stream memory when detached. My current code (working btw):
```gdscript
func _ready():
area_entered.connect(_on_area_entered)
$AudioStreamPlayer.finished.connect(_on_audio_stream_player_finished)
func _on_area_entered(area_that_entered: Area2D) -> void:
self.visible = false
get_node("CollisionShape2D").set_deferred("disabled", true)
get_node("AudioStreamPlayer").play()
func _on_audio_stream_player_finished() -> void:
queue_free()
```52Aug. 15, 2024
why no collision is detected if script is attached to ship sprite2D not to the area2D?omarI figured it out while typing here
the script changes the position of the node it is attached to
so when I attached it to the child (sprite2D) , only the sprite node was moving, but the parent (area2D) had its position staying still (I inspected using the remote tree to verify)
so in reality the area2D never moved and never collided with the health area12May. 11, 2024
About refactoringMLNow that we get first steps into refactoring, are we going to write some automated tests at some point as well? I'd really appreciate it. 21Aug. 11, 2024
Any downside to using "Node" as base node type for scenes?michaelinwordsI'm noticing that sometimes the "Ship" is structured as an Area2D and other times as a Sprite2D, but the name doesn't reflect that - which I imagine will lead to confusion (even just as a solo dev) later on.
Is there any downside to instead making the Ship's base (and all scenes' base types) a simple Node? Then, we can specify its children as an Area2D and a Sprite2D. That way, no hidden functionality (from the Area2D or Sprite2D) is assumed and we never have to guess or remember which node type it is; it would always be a simple Node.
What do you think of designing/structuring the scene this way?11May. 26, 2024
Crazy movement of the ship and morewell-off-apeHi, so two strange things happend.
1) When I opened space_level.tscn and went on to add the health packs, the little cross we use to guide the placing of the elements on the viewport (sorry, I don't remember its name) was placed diagonally in relation to the health pack (and no on its center), so to place them was very weird, since I wasn't expecting that to happen.
2) Still about the space_level.tscn: even though the code for the ship movement is correct (there's not a single line that's different in the script) its movement is extremelly weird, for exemple: it moves very slowly sideways and very fast diagonally (the input outcomes generate random results); also, the rotation is not being calculated, so it aways points to the right side. But, again, the script is the exact same.
Basically, I understood the lesson, but I just don't get it why this is happening, because I followed every step instructed.
I hope you guys can help me. Thanks in advance.
10Nov. 05, 2024
“Change Node” option is missing. What do I do now?defensive-tarsierUnfortunately I cannot attach a screenshot. Nothing is listed under the “Rename” option. Is there a hotkey I could use to bypass this?10Oct. 24, 2024
Direction.length changed to Velocity.lengthMaziHello!
Is there any reason to changed this (it is in M4 L5):
```gdscript
if direction.length() > 0.0:
rotation = velocity.angle()
```
to this (it is in M5 L3):
```gdscript
if velocity.length() > 0.0:
roation = velocity.angle()
```
Just because it was not mentioned or I just missed something? If I'm correct direction and velocity is the "same" vector2 and that is why I can't see any difference between the two codes.30Aug. 25, 2024
Unexpected behaviourrowdy-rhinocerosI was adjusting the location of the adjusted ship scene (after the area2d conversion) and I accidentally only selected the children and moved then, meaning that there was a huge displacement between the children and the root node/scene. Then I played it and it could visually only move to the right, when clicking any of the other three direction, the ship disappeared, but came back when clicking right again. I then put the children back to the same location as the root and all worked again as intended. I saw thee same behavior in the space _level scene (I only changed the placement inside the ship scene!) 10Aug. 25, 2024
Finding Health_Pack.tscn from prior lessonenraged-manateeHi, I did the lesson prior where we created the Health pack file. I remember saving the health pack, per the instructions, but went back during this lesson and cannot find it anywhere. I do see a health_pack.gd file. Did I mistakenly save the health_pack as .gd? I do remember saving the file, but wasn't paying attention, so I chose the default format. Could that have been .gd?
I still have one instance(?) of the Area2D HealthPack in the **Space Level.tscn** which displays the icon and collision shape. Is there a way to use the health_pack.gd file and Area2D instance to recreate the health_pack.tscn?
Hope this makes sense! 20Aug. 20, 2024
Refactoring means overlapping?single-dinosaurIf I understood correctly, when you refactor a scene, the scene gets modified forever. Does Godot keep track of the different versions you have? For example, would there be a way to go back to the "Sprite2d" version of the ship.tscn?10Aug. 13, 2024
Errors with area_enteredasricbWhen I run the scene I get an error, although everything still works.
-> E 0:00:00:0831 health_pack.gd:5 @ _ready(): Signal 'area_entered' is already connected to given callable 'Area2D(health_pack.gd)::_on_area_entered' in that object.
I have tried commenting the code in _ready and it works without the error.10Jul. 17, 2024
"metadata" in remote scene treeSebHello,
when I opened the remote scene tree, I had a metadata node in addition to the others. It was fun to try figuring out what are the metadata used by a godot game.
But, maybe it should not appear as it does not in the illustration above. I'm using "learn-2d-gamedev-projects-0.3.1-linux/".
(So far the course is really interesting.)30Apr. 02, 2024
What is the purpose of changing the root node?bartlomiejI couldn't really catch why we had to change the root node of ship from sprite2d to area2d. Wouldn't it work the same if we were to add a child node of area2d to the ship's root node (sprite2d at the time)?
30Mar. 14, 2024
About "position" variable when refactoring the ship script?gorohaWhen refactoring the ship script, we change the **"extends Sprite2D"** to **"extends Area2D"**, my understanding is "**position**" variable is now belonged to Ship node (**Area2D** node), is it correct?
And because **Sprite2D** is a child of Ship (**Area2D**), so when "**position**" of Ship changed, the position of all its children nodes will be changed as well (included the sprite of **Sprite2D** node that responsible to display the ship image)?
20Mar. 11, 2024
Refactoring of variables and functionsSalazarThis might be a bit off-topic but, is there a proper way or a way you would recommend to refactor Variables and Functions other than just use Replace and then search for every use of those variables/functions to update them as well? Specially when you have variables or function being called from other .gd files.20Mar. 07, 2024
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.