June 2018
Beginner to intermediate
298 pages
7h 38m
English
The Rock is emitting the signal, but it needs to be connected in Main. You can't use the Node tab to connect it, because the Rock instances are being created in code. Signals can be connected in code as well. Add this line to the end of spawn_rock():
r.connect('exploded', self, '_on_Rock_exploded')
This connects the rock's signal to a function in Main called _on_Rock_exploded(). Create that function, which will be called whenever a rock sends its exploded signal:
func _on_Rock_exploded(size, radius, pos, vel): if size <= 1: return for offset in [-1, 1]: var dir = (pos - $Player.position).normalized().tangent() * offset var newpos = pos + dir * radius var newvel = dir * vel.length() * 1.1 spawn_rock(size - 1, newpos, ...
Read now
Unlock full access