15 lines
445 B
GDScript
15 lines
445 B
GDScript
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
|