godot-tank-test/tank-round.gd
2022-10-15 19:37:05 +02:00

20 lines
381 B
GDScript

extends RigidBody
var life_span = 0
func _ready():
set_contact_monitor(true)
set_max_contacts_reported(5)
set_fixed_process(true)
connect("body_enter", self, "on_hit")
func _fixed_process(delta):
life_span += delta
if life_span > 5:
print("removed shot")
remove_and_skip()
func on_hit(other):
# cannot remove node right here as this would break exec
life_span = 5