1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-26 06:24:18 +00:00
the-cold-night/src/entities/behaviours/BulletSpawn.gd

17 lines
507 B
GDScript3
Raw Normal View History

2022-04-03 00:09:19 +00:00
extends Position2D
# Items
onready var bullet = preload("res://src/entities/Bullet.tscn")
onready var spawner = get_node("/root/Game/PhaseOne/PhaseOneContainer/Player")
func _process(_delta):
if Input.is_action_just_pressed("shoot"):
_on_Click()
func _on_Click():
2022-04-03 00:37:44 +00:00
var new_bullet = bullet.instance()
new_bullet.set_position(spawner.position)
var bullet_rotation = rad2deg(new_bullet.get_angle_to(get_global_mouse_position()))
new_bullet.set_rotation_degrees(bullet_rotation)
add_child(new_bullet)