I have an enemy that fires bullets at the player even when off the screen, however when the enemy instances a bullet outside of the screen the bullet won’t move until it is shown on the screen and the bullets stack until they are drawn.
Node tree:
-Bullet(Area2D)
-CollisionShape2D
-Sprite2D
-VisibleOnScreenNotifier2D
-AnimationPlayer
Bullet Code:
Extends Area2D
func _ready():
$AnimationPlayer.play(“Summon Animation”)
look_at(PlayerAutoLoad.Playerinfo.Global_position)
func _physics_process(delta):
Position += (Vector2.RIGHT*250).rotated(rotation) * delta
func _on_visible_on_screen_enabler_2d_screen_exited():
queue_free()