ChronoSpace/scenes/weapon/shotgun/shotgun.gd

18 lines
662 B
GDScript

class_name Shotgun extends "res://scenes/weapon/weapon.gd"
@onready var bullet = preload("res://scenes/bullet/bulletShotgun/bulletShotgun.tscn")
@export var bulletAmount: int = 5
func attack():
if cooldownTimer.is_stopped():
shoot.play()
spawnBullet()
cooldownTimer.start(cooldown)
func spawnBullet():
for i in range(0, bulletAmount):
var newBullet = bullet.instantiate()
newBullet.spawn(bulletPoint.global_position, get_parent().get_parent().rotation + getSpread(), damage, range, penetration)
newBullet.fromTimeGhost = get_parent().get_parent().is_in_group("timeGhost")
get_tree().get_first_node_in_group("bulletPool").add_child(newBullet)