Added rotatable laser weapon
This commit is contained in:
parent
1ee0b529a8
commit
154da5104e
10 changed files with 99 additions and 13 deletions
15
scripts/Weapons/laser.gd
Normal file
15
scripts/Weapons/laser.gd
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue