24 lines
635 B
GDScript
24 lines
635 B
GDScript
extends Area2D
|
|
|
|
signal shooted
|
|
@export var bullet: PackedScene
|
|
@onready var timer: Timer = %Timer
|
|
|
|
func _physics_process(_delta: float) -> void:
|
|
var enemies_in_range = get_overlapping_bodies()
|
|
if enemies_in_range.size() > 0:
|
|
var target = enemies_in_range.front()
|
|
look_at(target.global_position)
|
|
|
|
func shoot() -> void:
|
|
var new_bullet = bullet.instantiate()
|
|
new_bullet.global_position = %ShootingPoint.global_position
|
|
new_bullet.global_rotation = %ShootingPoint.global_rotation
|
|
%ShootingPoint.add_child(new_bullet)
|
|
shooted.emit()
|
|
|
|
|
|
func _on_player_level_up(_level: int) -> void:
|
|
pass
|
|
# timer.wait_time = 0.5 - (level * 0.1)
|