ape-ame/bullet.gd

22 lines
359 B
GDScript3
Raw Normal View History

2024-04-16 20:29:45 -04:00
extends RigidBody2D
var bounces = 0
2024-04-18 19:45:52 -04:00
func _process(delta):
$Sprite2D.global_rotation = linear_velocity.angle() + deg_to_rad(90)
2024-04-16 20:29:45 -04:00
func hit(body):
if body.is_in_group("destructible"):
if body.has_method("destroy"):
body.destroy()
else:
body.queue_free()
queue_free()
else:
bounces += 1
#print(bounces)
if bounces >= 2:
queue_free()