Change how different sensor types ar handled
This commit is contained in:
@@ -14,14 +14,20 @@ scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("2_qf1yp")
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=338110309]
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -50.0
|
||||
offset_top = -350.0
|
||||
offset_top = -300.0
|
||||
offset_right = 50.0
|
||||
offset_bottom = -150.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
pivot_offset = Vector2(50, 300)
|
||||
theme_override_font_sizes/font_size = 80
|
||||
text = "N"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
justification_flags = 161
|
||||
|
||||
[node name="MovableControl" type="Control" parent="." unique_id=124696843 node_paths=PackedStringArray("move_target")]
|
||||
|
||||
@@ -5,6 +5,7 @@ class_name CompassWidgetNode
|
||||
@export_range(0., 359., 0.1) var north_deg = 0.
|
||||
var north_rad: float
|
||||
var indicator: Sprite2D
|
||||
var label: Label
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -13,8 +14,31 @@ func _ready() -> void:
|
||||
north_deg = 0.
|
||||
north_rad = deg_to_rad(north_deg)
|
||||
indicator = get_node("CompassIndicator")
|
||||
label = get_node("Label")
|
||||
|
||||
func _update_data():
|
||||
if indicator == null:
|
||||
if label == null:
|
||||
return
|
||||
indicator.rotation = host_vehicle.heading_rad
|
||||
#label.rotation = -host_vehicle.heading_rad
|
||||
label.text = get_direction_label(host_vehicle.heading_rad)
|
||||
|
||||
func get_direction_label(heading_rad):
|
||||
var heading_deg = rad_to_deg(heading_rad)
|
||||
if 0 <= heading_deg and heading_deg <= 22.5:
|
||||
return 'N'
|
||||
elif 22.5 < heading_deg and heading_deg <= 67.5:
|
||||
return "NE"
|
||||
elif 67.5 < heading_deg and heading_deg <= 112.5:
|
||||
return "E"
|
||||
elif 112.5 < heading_deg and heading_deg <= 157.5:
|
||||
return "SE"
|
||||
elif 157.5 < heading_deg and heading_deg <= 202.5:
|
||||
return "S"
|
||||
elif 202.5 < heading_deg and heading_deg <= 247.5:
|
||||
return "SW"
|
||||
elif 247.5 < heading_deg and heading_deg <= 292.5:
|
||||
return "W"
|
||||
elif 292.5 < heading_deg and heading_deg <= 337.5:
|
||||
return "NW"
|
||||
else:
|
||||
return "N"
|
||||
|
||||
Reference in New Issue
Block a user