June 2018
Beginner to intermediate
298 pages
7h 38m
English
Open the Main scene and add a Timer node called EnemyTimer. Set its One Shot property to On. Then, in Main.gd, add a variable to reference your enemy scene (drag it into the Inspector after saving the script):
export (PackedScene) var Enemy
Add the following code to new_level():
$EnemyTimer.wait_time = rand_range(5, 10)$EnemyTimer.start()
Connect the EnemyTimer timeout signal, and add the following:
func _on_EnemyTimer_timeout(): var e = Enemy.instance() add_child(e) e.target = $Player e.connect('shoot', self, '_on_Player_shoot') $EnemyTimer.wait_time = rand_range(20, 40) $EnemyTimer.start()
This code instances the enemy whenever the EnemyTimer times out. When you add shooting to the enemy, it will use the same process you ...
Read now
Unlock full access