open-fpsz/entities/weapons/grenade_launcher/grenade_launcher.gd
2024-05-07 14:21:10 +00:00

30 lines
816 B
GDScript

class_name GrenadeLauncher extends Node3D
@export_range(0, 24) var ammo : int = 24
@export var fire_rate : float = 1. # seconds
@export var reload_time : float = 1. # seconds
@export_category("Animations")
@export var anim_player : AnimationPlayer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func trigger() -> void:
# play the fire animation
anim_player.play("fire")
# init projectile
var projectile : Node3D = $ProjectileSpawner.new_projectile(
GrenadeLauncherProjectile,
owner.linear_velocity,
owner.match_participant_component
)
# add to owner of player for now
GameManager.mode.add_child(projectile)
func _on_visibility_changed() -> void:
if self.visible:
anim_player.play("equip")
#self.sounds.play("equip")