Mostly health
This commit is contained in:
20
scenes/gun.gd
Normal file
20
scenes/gun.gd
Normal file
@ -0,0 +1,20 @@
|
||||
extends Area2D
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var enemies_in_range = get_overlapping_bodies()
|
||||
if enemies_in_range.size() > 0:
|
||||
var closest_target = enemies_in_range.front()
|
||||
look_at(closest_target.global_position)
|
||||
|
||||
func shoot():
|
||||
const BULLET = preload("res://scenes/bullet.tscn")
|
||||
var new_bullet = BULLET.instantiate()
|
||||
new_bullet.global_position = %shootingPoint.global_position
|
||||
new_bullet.global_rotation = %weponPivot.global_rotation
|
||||
%shootingPoint.add_child(new_bullet)
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
shoot()
|
Reference in New Issue
Block a user