godot-tank-test/tank-round.gd

20 lines
381 B
GDScript3
Raw Permalink Normal View History

extends RigidBody
var life_span = 0
2017-09-13 16:59:33 +02:00
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
2017-09-13 16:59:33 +02:00
if life_span > 5:
print("removed shot")
remove_and_skip()
func on_hit(other):
# cannot remove node right here as this would break exec
2022-10-15 19:37:05 +02:00
life_span = 5