Space Rocks! Astroid Placement issue

Godot Version

Version 4.3

Question

`I have my main code used here. The player and the bullet and the HUD work fine, however the astroid is always moving to the top left and continuously teleporting somehow. Here’s the code:

extends Node

var level = 0
var score = 0
var playing = false

@export var rock_scene : PackedScene

var screensize = Vector2.ZERO

#func _ready() → void:
#screensize = get_viewport().get_visible_rect().size
#for i in 3:
#spawn_rock(3)

func spawn_rock(size, pos=null, vel=null):
if pos == null:
$RockPath/RockSpawn.progress = randi()
pos = $RockPath/RockSpawn.position
if vel == null:
vel = Vector2.RIGHT.rotated(randf_range(0, TAU)) * randf_range(50, 125)
var r = rock_scene.instantiate()
r.screensize = screensize
r.start(pos, vel, size)
call_deferred(“add_child”, r)
r.exploded.connect(self._on_rock_exploded)

func _on_rock_exploded(size, radius, pos, vel):
if size <= 1:
return
for offset in [-1, 1]:
var dir = $Player.position.direction_to(pos).orthogonal() * offset
var newpos = pos + dir * radius
var newvel = dir * vel.length() * 1.1
spawn_rock(size - 1, newpos, newvel)

func new_game():
# remove any old rocks from previous game
get_tree().call_group(“rocks”, “queue_free”)
level = 0
score = 0
$HUD.update_score(score)
$HUD.show_message(“Get Ready!”)
#$Player.reset()
await $HUD/Timer.timeout
playing = true

func new_level():
level += 1
$HUD.show_message(“Wave %s” % level)
for i in level:
spawn_rock(3)

func _process(delta):
if not playing:
return
if get_tree().get_nodes_in_group(“rocks”).size() == 0:
new_level()
What am I doing wrong?

It looks ok, what is the code for the rock?