blob: 7f1231bc8fa164ae7e1b68813fd08f01d00b8163 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
extends StaticBody2D
var projectile
@onready var ProjectileScene = preload("res://Scenes/Entities/Enemies/Projectile.tscn")
func _on_timer_timeout():
if projectile:
await projectile.tree_exited
projectile = ProjectileScene.instantiate()
projectile.tree_exited.connect(func():
projectile = null
)
projectile.hit.connect(func():
Global.player.take_damage(1)
)
projectile.global_position = $ProjectileStart.global_position
projectile.target = Global.player.position
projectile.scale = Vector2(0.75, 0.75)
projectile.speed = 60
get_tree().current_scene.add_child(projectile)
|