func _on_Aster_timer_timeout():
$Aster_path/Aster_spwan.set_offset(randi())
var Aster= Asteroid.instance()
add_child(Aster)
Aster.position=$Aster_path/Aster_spwan.position
var direction =$Aster_path/Aster_spwan.rotation+ PI/2
direction += rand_range(-PI/4,PI/4)
Aster.rotation = direction
Aster.set_linear_velocity(Vector2(rand_range(Aster.MIN_SPEED,Aster.MAX_SPEED),rand_range(Aster.MIN_SPEED,Aster.MAX_SPEED)).rotated(direction))
You have a lot of choices of what you can do, but here is one way in Godot 3.1:
1: Add a signal asteroid_hit to your asteroid object.
signal asteroid_hit
2: Emit a signal when you detect a collision with a shot. Return your location (a Vector2) and your size (I assume you will have about 3 sizes like the arcade game does).
emit signal("asteroid_hit", cur_location, cur_size)
# play animation or sounds here
You will want to call queue_free() on your asteroid after your explode animation and sounds are done.
If you are using Tween to do the animation, you can connect to the tween end signal. Otherwise
you could make it happen in a timer after a second or so:
4: Also in your main script, implement on_asteroid_hit function that takes the parameters from your emitted signal and makes baby asteroids at that location
# When an asteroid is hit, make two smaller child asteroids at that location
func on_asteroid_hit(location, size):
var new_aster
for i in range(0, 1): # this could be a random number if you don't always spawn 2
var size = get_smaller_size(size)
if size > MIN_SIZE:
new_aster = $Asteroid.instance()
new_aster.position = location
# set the direction etc
# add_child(new_aster)