22 lines
634 B
GDScript
22 lines
634 B
GDScript
extends Node2D
|
|
|
|
@export var projectile_prefab : Resource
|
|
@onready var projectilePrefab : PackedScene = load(projectile_prefab.resource_path)
|
|
|
|
func _process(delta):
|
|
rotate_to_pointer()
|
|
|
|
if Input.is_action_just_pressed("attack"):
|
|
spawn_projectile(self.global_position, self.rotation, 100, 1)
|
|
pass
|
|
|
|
func rotate_to_pointer():
|
|
look_at(get_global_mouse_position())
|
|
#TODO Implement Joystick Aiming
|
|
|
|
func spawn_projectile(pos : Vector2, dir : float, speed: float, damage : int):
|
|
var projectile = projectilePrefab.instantiate()
|
|
projectile.global_position = pos
|
|
projectile.rotation = dir
|
|
get_tree().root.add_child(projectile)
|
|
pass
|