I am making a simple Asteroids game, where the player shoots and destroys asteroids to accumulate points. I am currently building the asteroid logic - when the large asteroids are hit they will break into medium asteroids, and when the mediums are hit, they will turn into small asteroids, and then they will be fully destroyed.
However, when I shoot the asteroid I am hit with the following error:
Invalid set index ‘size’ (on base: ‘Area2D’) with value of type ‘int’.
Here are the four functions that the message points to:
scripts/game.gd:35
func spawn_asteroid(pos,size):
var a = asteroid_scene.instantiate()
a.global_position = pos
a.size = size
a.connect("exploded", _on_asteroid_exploded)
asteroids.add_child(a)
scripts/game.gd:26
func _on_asteroid_exploded(pos, size):
for i in range(2):
match size:
Asteroid.AsteroidSize.LARGE:
spawn_asteroid(pos, Asteroid.AsteroidSize.MEDIUM)
Asteroid.AsteroidSize.MEDIUM:
spawn_asteroid(pos, Asteroid.AsteroidSize.SMALL)
Asteroid.AsteroidSize.SMALL:
pass
Beautiful! Thank you so much, this was the issue. I am unsure how the script changed tbh, don’t recall fiddling with it. I’ve solely use UE for the last 3 years so honestly I have no idea how to debug with Godot lol
No problem those “script disapeared” ones are always crazy, seen a lot on the forum the past few days maybe a 4.3 issue? Type annotation help tons of course.