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.
_destroy function clarification & diagram feedbackwell-to-do-owl```gdscript
func _destroy() -> void:
set_physics_process(false)
_visual.destroy()
_visual.tree_exited.connect(queue_free)
```
I just wanted clarification on the destroy function, we call `_visual.destroy()`** so that the fireball (or whatever FX) destroys itself in its own way (whatever tweens, animations, etc that correspond to making the FX disappear in a visually appealing way). Within that destroy function for the `_visual` instance is it's own `queue_free()` call, which makes the visual component leave the scene tree and get deleted. When things leave the scene tree they emit a `tree_exited` signal. So what we're doing is when the visual component is destroyed we destroy this node (`projectile_3d`) as well.
Do I have that right? Sorry if it's long-winded, it was a lot to process for me for two lines of code haha.
----
Thanks for the great lesson! It was very interesting and informative as someone who does real-time VFX work in Unreal.
**Spell Check**
Small error I found:
In the practice for this lesson I believe there's a mistake as it says:
> It contains one instance of the bullet scene, which you will.Open the scene bullet.tscn to code the bullet's movement and visuals.
21Jul. 10, 2024
Unnecessary/Confusing variablestheodoruHi! I was really confused by one part of the code which is this part:
var distance := speed * delta
var motion := -transform.basis.z * distance
position += motion
_traveled_distance += distance
At first it made perfect sense to me that the traveled distance variable we create at the start of the script would be calculated by the speed*delta, but then when we got to the physics process we create a different variable named distance, which isn't distance at all? It's rather a crunched speed variable. To me this, combined with the following motion variables, complicated things beyond understanding for me. (in my mind, motion is what occurs when position is animated by a vector through a timestep variable, like delta)
I rewrote the four lines to:
position += -transform.basis.z * speed * delta
traveled_distance += speed * delta
Where the position calculation follows the regular vector * speed * delta formula and travelled distance directly calculating the distance. This might just be very much a personal preference thing OR I've missed an important point you had with creating the two extra variables. Learned a ton of useful other things this lesson though:)30Dec. 09, 2024
I have a couple of questions about the lessonwhite-butterfly
1) Why call `set_physics_process(false)` if we are destroying the instance?
2) I've heard the opinion that directly modifying the `transform` property can lead to bugs, where an object might pass through textures or get stuck in them. Is this true in practice? 10Sep. 16, 2024
L6.P1 does not require `tree_exited` signalvast-baboonHowdy! Just thought I'd let ya'll know that the practice for L6.P1 will pass all of its checks with
```gdscript
# Destroy the bullet when it travels past the maximum range.
if traveled_distance > max_range:
set_physics_process(false)
visual.destroy()
```
even though the instructions state
> The bullet plays the skin's destroy animation after traveling a certain distance and destroys itself **when the skin exits the scene tree**.
ex.
```gdscript
# Destroy the bullet when it travels past the maximum range.
if traveled_distance > max_range:
set_physics_process(false)
visual.destroy()
visual.tree_exited.connect(queue_free)
```10Sep. 14, 2024
Discrepancy in radius sizevast-baboonEarly in the lesson, it states "...using a Sphere shape with a radius of **0.3** meters for the CollisionShape3D node." The image just after that shows a radius of **0.5** meters.
Not a big deal by any means. Just a bit confusing while following along.10Sep. 14, 2024
"Coding the visuals" lesson section - first half jumps back and forthMelabelaI found the flow in early part of this section (first 3 code blocks) a bit confusing:
- 1. "Open the projectile script and define the variable under the first line:"
- `@export var projectile_vfx`...
- 2. Jump to "(I prepared a) little script ... `projectile_skin_3d.gd`..."
- 3. "Back to our `projectile_3d.gd` script..."
--
My experience:
- For 1. - Wasn't clear which script to add line to. At this point in the lesson, `projectile_3d.gd` script hadn't been mentioned/created...
- Anyways I created the script file, and added `projectile_vfx` line.
- For 2. - Wasn't sure what to do with `projectile_skin_3d.gd` script code block. I copied and pasted this, and created 2nd script under `lessons/projectile_skin_3d.gd`
- For 3. - Had to go back and update the first line of `projectile_3d.gd`
--
Perhaps would flow more naturally if rearranged as:
- First discuss and Handle point 2. - `projectile_skin_3d.gd` script
- Goto current point 3. - Create `projectile_3d.gd` script, and set first line `class_name Projectile3D`...
- Then do current point 1 - define `@export var projectile_vfx` line, under the first line.30Aug. 23, 2024
L6.P1 Trying to assign value of type 'bullet_skin.gd' to a variable of type 'bullet_skin.gd' errorsiwokuwhy am I getting this error when doing as follows
` visual = bullet_skin_scene.instantiate()`
had to remove the type 'BulletSkin' from `var visual: BulletSkin = null` on line 14 for it to work
where can we check the solution for the practices?50Aug. 07, 2024
L6.P1 Moving the bullet: first step is solved alreadyTJHi! Just a quick feedback remark. As I was doing practice L6.P1, Moving the bullet, I noticed the first step was already completed in the workbook project. So the property `bullet_skin_scene` came pre-assigned with the correct result.10Jul. 21, 2024
Could not find ProjectileSkin3D in current scopemichaelgame_devI've created the projectile_3d scene but when adding the _visual variable.
```gdscript
class_name Projectile3D extends Area3D
@export var projectile_vfx : PackedScene = null
var _visual: ProjectileSkin3D = null
func _ready() -> void:
_visual = projectile_vfx.instantiate()
add_child(_visual)
_visual.appear()
```
I'm consistently getting an error on the *visual assignment. I double checked the spelling in the `projectile_*skin_3d` script. All looks fine there. Also reloaded the project.
50Jul. 21, 2024
transform vs global_transformTJHi! I have a question about which transform to use. The lesson says:
> A node's `transform` property represents the node's position, rotation, and scale in the world.
Godot's documentation (for version v4.2.2 stable) says about `transform`:
> Local space Transform3D of this node, with respect to the parent node.
For property `global_transform` the documentation says:
> World3D space (global) Transform3D of this node.
So should the lesson actually use `global_transform` instead of `transform`? Probably in this case they would result in the same calculated distances because the parent of the projectile does not have any transformations applied to it. But maybe it's good that we realize this difference now before subsequent lessons build upon thinking that `transform` is the world position or anything, which might not always be the case.20Jul. 21, 2024
@Tool crashes godotMarcJAfter adding the code to convert the projectile to a tool, I can see the projectile run in the editor but as soon as it finishes flying off the godot editor crashes. I've removed the @tool keyword in the meantime.30Jul. 04, 2024
extends from HitBox3DMarcJIn some of the code above Projectile3D extends HitBox3D instead of Area3D. I assume that's a mistake since the final code shows Area3D
Also in the section where you change the projectile to a tool there's a Diff that shows that you're removing the class name line, I think that may also be a mistake
```gdscript
-class_name Projectile3D extends HitBox3D
+@export var projectile_vfx: PackedScene = null: set = set_projectile_vfx
```
30Jul. 04, 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.