extends KinematicBody

var hitsomething = false

var angle = Vector3(0,0,0)
var speed = 65
var power = 11

var max_time = 6
var time = 0


func _physics_process(delta):
	var forward_dir = -global_transform.basis.z.normalized()
	move_and_collide(forward_dir * speed * delta)
	
	time += delta
	if time >= max_time:
		queue_free()

func _on_Area_body_entered(body):
	if !body.is_in_group("player") and !body.is_in_group("bullet"):
		print(body.name)
		if hitsomething == false:
			if body.has_method("take_damage"):
				body.take_damage(power, ext.DAMAGE_TYPES.RANGED, null)


		hitsomething = true
		if !body.is_in_group("damage"): queue_free()
		


func _on_Area_area_entered(area):
	if area.has_method("take_damage"):
		area.take_damage(power, ext.DAMAGE_TYPES.RANGED)
		queue_free()
