extends Node2D ## Shortcut to get_parent() @onready var ship: Ship = get_parent() var expected_rotation: float = 0.0: set(value): if value > 180: expected_rotation = value - 360 elif value < -180: expected_rotation = 360 + value else: expected_rotation = value func _physics_process(_delta) -> void: ship.engine.acceleration_axis = Input.get_axis("deccelerate", "accelerate") ship.engine.rotation_axis = Input.get_axis("rotateleft", "rotateright") for weapon in ship.weapons.list: match weapon.action_id: "primary": weapon.shoot_request = Input.get_action_strength("shootprimary") "secondary": weapon.shoot_request = Input.get_action_strength("shootsecondary") if "gun_rotation" in weapon: var angle_to_mouse = ship.hull.position.angle_to_point(get_global_mouse_position()) expected_rotation = rad_to_deg(angle_to_mouse - ship.hull.rotation) weapon.gun_rotation = expected_rotation