godot-tank-test/tank-round.gd
2024-07-23 00:25:52 +02:00

20 lines
393 B
GDScript

extends RigidBody3D
var life_span = 0
func _ready():
set_contact_monitor(true)
set_max_contacts_reported(5)
set_fixed_process(true)
connect("body_enter", Callable(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