Peashooters
This commit is contained in:
parent
161f87da75
commit
68cfe89f1d
47 changed files with 1571 additions and 279 deletions
|
|
@ -0,0 +1,33 @@
|
|||
extends Node
|
||||
|
||||
const projectile := preload("uid://ciqhjwh4sfe3u")
|
||||
|
||||
@export var projectile_transform : Marker2D
|
||||
|
||||
var detected : bool = false
|
||||
var can_shoot : bool = true
|
||||
|
||||
@onready var timer := $Timer
|
||||
@onready var entity : Entity = get_parent()
|
||||
|
||||
func is_shooting():
|
||||
return detected and can_shoot and entity.disabled == false
|
||||
|
||||
func _on_generic_hurtbox_collision_start() -> void:
|
||||
detected = true
|
||||
|
||||
func _on_generic_hurtbox_collision_end() -> void:
|
||||
detected = false
|
||||
|
||||
func shoot():
|
||||
if can_shoot == false:
|
||||
return
|
||||
can_shoot = false
|
||||
timer.start()
|
||||
var proj = projectile.instantiate()
|
||||
get_tree().current_scene.get_node("%Projectiles").add_child(proj)
|
||||
proj.global_transform = projectile_transform.global_transform
|
||||
proj.source = entity
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
can_shoot = true
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b0ka8lb5kl1fd
|
||||
Loading…
Add table
Add a link
Reference in a new issue