24 lines
561 B
GDScript
24 lines
561 B
GDScript
extends Area2D
|
|
|
|
const SPEED: int = 200
|
|
|
|
var player_position: Vector2
|
|
var velocity: Vector2 = Vector2.ZERO
|
|
|
|
|
|
func init(spawn_position: Vector2, shoot_position: Vector2) -> void:
|
|
position = spawn_position
|
|
player_position = shoot_position
|
|
velocity = position.direction_to(player_position).normalized() * SPEED
|
|
$Sprite.rotation = player_position.angle_to_point(position) + deg2rad(180)
|
|
return
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
position += velocity * delta
|
|
return
|
|
|
|
|
|
func _on_Lifetime_timeout():
|
|
call_deferred('queue_free')
|