22 lines
590 B
GDScript
22 lines
590 B
GDScript
extends BaseWidgetNode
|
|
class_name CompassWidgetNode
|
|
|
|
|
|
@export_range(0., 359., 0.1) var north_deg = 0.
|
|
var north_rad: float
|
|
var indicator: Sprite2D
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
super._ready()
|
|
if north_deg == null:
|
|
north_deg = 0.
|
|
north_rad = deg_to_rad(north_deg)
|
|
Signals.heading_updated.connect(_on_heading_updated)
|
|
indicator = get_node("CompassIndicator")
|
|
|
|
func _on_heading_updated(sensor_ip: String, heading_rad: float):
|
|
if not check_valid_sensor(sensor_ip, "MAG"):
|
|
return
|
|
indicator.rotation = north_rad + heading_rad
|