I have a bullet node of type area2d with a collision2d and a sprite2d. I want it to hit another area2d with a collision2d and sprite2d. My code for the bullet is as follows:
@export var speed = 1000
var vortex_scene : PackedScene =preload("res://scenes/vortex.tscn")
func _ready():
pass
func _physics_process(delta):
position += transform.x * speed * delta
func _on_Bullet_body_entered(body):
print('hit')
queue_free()
func _on_VisibleOnScreenNotifier2D_screen_exited():
print('exited screen')
queue_free()```
my code for the shooter (it orbits the target):
```extends CharacterBody2D
var bullet_scene : PackedScene =preload("res://scenes/Bullet.tscn")
var radius:float = 160
var angle:float = PI/2
var speed:float = 2.2
func _ready() -> void:
pass
func _process(delta):
circular_motion()
look_at(Vector2(320, 180)) # <- center of my screen
if Input.is_action_just_pressed("fire"):
fire()
func circular_motion():
angle += speed * get_process_delta_time() * Input.get_axis("counterclockwise", "clockwise")
var x_pos = cos(angle)
var y_pos = sin(angle)
# (320, 180) is the center of the screen
position.x = radius * x_pos + 320
position.y = radius * y_pos + 180
func fire():
var b = bullet_scene.instantiate()
owner.add_child(b)
b.transform = self.global_transform```
and my code for the target:
```extends Area2D
var rotation_speed = 3
func _ready() -> void:
position = Vector2(320, 180)
func _process(delta: float) -> void:
rotation += rotation_speed * delta```
and I've attached what my folder looks like. I'm sorry for the dumb question. thank you for any help