NEON-29: Show player world x,y,z in prototype HUD
Add UICanvas/PlayerPositionLabel (top-left) and refresh each frame from main.gd.pull/41/head
parent
1867e3e45c
commit
173c348030
|
|
@ -992,3 +992,22 @@ offset_right = -12.0
|
||||||
offset_bottom = -8.0
|
offset_bottom = -8.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
autowrap_mode = 3
|
autowrap_mode = 3
|
||||||
|
|
||||||
|
[node name="PlayerPositionLabel" type="Label" parent="UICanvas" unique_id=9000003]
|
||||||
|
layout_mode = 0
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 220.0
|
||||||
|
offset_bottom = 72.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme_override_colors/font_color = Color(0.92, 0.95, 0.98, 1)
|
||||||
|
theme_override_colors/font_outline_color = Color(0.08, 0.08, 0.1, 1)
|
||||||
|
theme_override_constants/outline_size = 6
|
||||||
|
theme_override_font_sizes/font_size = 15
|
||||||
|
text = "x: —\ny: —\nz: —"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ extends Node3D
|
||||||
## (see `isometric_follow_camera.gd`).
|
## (see `isometric_follow_camera.gd`).
|
||||||
## Prototype: two random short bumps (sibling StaticBody3D under NavigationRegion3D; see
|
## Prototype: two random short bumps (sibling StaticBody3D under NavigationRegion3D; see
|
||||||
## `random_floor_bumps.gd`) before nav bake.
|
## `random_floor_bumps.gd`) before nav bake.
|
||||||
|
## Prototype HUD: world `CharacterBody3D` position in `UICanvas/PlayerPositionLabel`.
|
||||||
|
|
||||||
const MOVE_REJECT_MSG_SECONDS: float = 4.0
|
const MOVE_REJECT_MSG_SECONDS: float = 4.0
|
||||||
|
|
||||||
|
|
@ -29,10 +30,12 @@ var _dev_obstacle_smoke: Node3D
|
||||||
@onready var _authority: Node = $PositionAuthorityClient
|
@onready var _authority: Node = $PositionAuthorityClient
|
||||||
@onready var _radius_preview: Node3D = $World/InteractionMarkers
|
@onready var _radius_preview: Node3D = $World/InteractionMarkers
|
||||||
@onready var _move_reject_label: Label = $UICanvas/MoveRejectLabel
|
@onready var _move_reject_label: Label = $UICanvas/MoveRejectLabel
|
||||||
|
@onready var _player_pos_label: Label = $UICanvas/PlayerPositionLabel
|
||||||
@onready var _floor: StaticBody3D = $World/NavigationRegion3D/Floor
|
@onready var _floor: StaticBody3D = $World/NavigationRegion3D/Floor
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
set_process(true)
|
||||||
set_process_unhandled_key_input(true)
|
set_process_unhandled_key_input(true)
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
_dev_obstacle_smoke = get_node_or_null("World/NavigationRegion3D/Obstacle") as Node3D
|
_dev_obstacle_smoke = get_node_or_null("World/NavigationRegion3D/Obstacle") as Node3D
|
||||||
|
|
@ -54,6 +57,13 @@ func _ready() -> void:
|
||||||
_radius_preview.call("setup_player", _player)
|
_radius_preview.call("setup_player", _player)
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if not is_instance_valid(_player) or not is_instance_valid(_player_pos_label):
|
||||||
|
return
|
||||||
|
var p: Vector3 = _player.global_position
|
||||||
|
_player_pos_label.text = "x: %.3f\ny: %.3f\nz: %.3f" % [p.x, p.y, p.z]
|
||||||
|
|
||||||
|
|
||||||
func _on_target_chosen(world: Vector3) -> void:
|
func _on_target_chosen(world: Vector3) -> void:
|
||||||
_authority.call("submit_move_target", world)
|
_authority.call("submit_move_target", world)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue