29 lines
717 B
GDScript
29 lines
717 B
GDScript
extends Node2D
|
|
|
|
var direction = 1
|
|
@export var speed = Vector2.ZERO
|
|
@export var range = 1.0
|
|
@export var infinite_range = true
|
|
|
|
func _ready() -> void:
|
|
var player = get_tree().get_nodes_in_group("player")[0]
|
|
direction = player.aim_direction
|
|
if infinite_range == true: %RangeTimer.paused = true
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
position.x += (speed.x * direction) * delta
|
|
position.y += (speed.y) * delta
|
|
|
|
|
|
func _on_area_2d_area_entered(area: Area2D) -> void:
|
|
if area.is_in_group("enemy_hitbox"):
|
|
GlobalFunctions.queue_score(10)
|
|
area.get_parent().queue_free()
|
|
queue_free()
|
|
|
|
|
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
|
queue_free()
|
|
|
|
func _on_range_timer_timeout() -> void:
|
|
queue_free()
|