There’s always more than one way to something when coding, but some ways can optimize things while others are a little more messy.
I believe in what was noted above me here ‘if it works, it works’.
With that said sometimes implementing functions in certain ways can break the game in unexpected ways. For example, I created a function to use queue_free prior to this episode. Because we learned how to do it when we learned how to release the rocket objects, so I simply took that snippet of code, and use it to release my rocket.
So mine looks like this:
extends Area2D
#create global variables and connect nodes
@export var speed = 450
@onready var visible_notifier = $VisibleNotifier
@onready var area_enter = $"."
#create bullet movement
func _physics_process(delta):
global_position.x += speed*delta
#connect signals in the ready function
func _ready():
visible_notifier.screen_exited.connect(_on_screen_exited)
#kill the process
func _on_screen_exited():
queue_free()
#delete the rocket when the area is entered
func _on_area_entered(area):
queue_free()
I also added a second enemy, and because of the method I used to create the enemy when they ran into one another they would delete each other. This was fixed using the layer/mask as at the end of Lecture 12 for Alien Attack.
I hope this provided some insight as I’m now realizing that you wrote this post a while ago and have likely moved on to greater coding!