Added rotatable laser weapon

This commit is contained in:
2ndbeam 2024-05-12 21:19:44 +03:00
commit 154da5104e
10 changed files with 99 additions and 13 deletions

15
scripts/Weapons/laser.gd Normal file
View file

@ -0,0 +1,15 @@
extends Weapon
## Reference to Gun node
@onready var gun = $Gun
## Maximum gun rotation angle
@export var max_gun_rotation: float = 30.0
## Current gun rotation angle. Clamps with max_gun_rotation
var gun_rotation: float = 0.0:
set(value):
gun_rotation = clamp(value, -max_gun_rotation / 2, max_gun_rotation / 2)
update_gun()
## Updates gun sprite (and projectile spawner) rotation
func update_gun():
gun.rotation_degrees = gun_rotation