From 90290551f9fd58676dcd8c55b8b43c6303b5eb59 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 31 Oct 2026 01:39:21 -0500 Subject: [PATCH] Add debuging like UI info output; WIP implimintation for steering --- scenes/ui/base_ui.tscn | 68 ++++++++++++++++++- scenes/ui/ui_viewport.tscn | 1 - .../controllers/cpu_system/cpu_controller.gd | 56 ++++++++++++++- 3 files changed, 121 insertions(+), 4 deletions(-) diff --git a/scenes/ui/base_ui.tscn b/scenes/ui/base_ui.tscn index 14413ad..34fd37c 100644 --- a/scenes/ui/base_ui.tscn +++ b/scenes/ui/base_ui.tscn @@ -1,8 +1,11 @@ -[gd_scene load_steps=3 format=3 uid="uid://d0esuq6urlrjh"] +[gd_scene load_steps=4 format=3 uid="uid://d0esuq6urlrjh"] [ext_resource type="Script" uid="uid://dccwod1q2mvey" path="res://scenes/ui/base_ui.gd" id="1_mlarl"] [ext_resource type="PackedScene" uid="uid://be2rcw7fje32a" path="res://scenes/ui/ui_viewport.tscn" id="2_nn855"] +[sub_resource type="LabelSettings" id="LabelSettings_nn855"] +font_color = Color(0.38212836, 0.95692664, 0.523243, 1) + [node name="base_ui" type="Control"] layout_mode = 3 anchors_preset = 0 @@ -10,3 +13,66 @@ script = ExtResource("1_mlarl") [node name="ui_viewport" parent="." instance=ExtResource("2_nn855")] layout_mode = 0 +offset_right = 512.0 +offset_bottom = 512.0 +metadata/_edit_lock_ = true + +[node name="target_label" type="Label" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 23.0 +text = "Target: " +metadata/_edit_lock_ = true + +[node name="target_z_label" type="Label" parent="."] +layout_mode = 0 +offset_left = 63.0 +offset_top = 2.0 +offset_right = 79.0 +offset_bottom = 25.0 +text = "Z" +metadata/_edit_lock_ = true + +[node name="target_z" type="Label" parent="."] +layout_mode = 0 +offset_left = 79.0 +offset_top = 2.0 +offset_right = 119.0 +offset_bottom = 25.0 +metadata/_edit_lock_ = true + +[node name="target_x_label" type="Label" parent="."] +layout_mode = 0 +offset_left = 62.0 +offset_top = 31.0 +offset_right = 83.0 +offset_bottom = 80.0 +text = "X +" +metadata/_edit_lock_ = true + +[node name="target_x" type="Label" parent="."] +layout_mode = 0 +offset_left = 79.0 +offset_top = 31.0 +offset_right = 119.0 +offset_bottom = 54.0 +metadata/_edit_lock_ = true + +[node name="target_position_ab" type="Label" parent="."] +layout_mode = 0 +offset_left = 67.0 +offset_top = 59.0 +offset_right = 107.0 +offset_bottom = 82.0 +label_settings = SubResource("LabelSettings_nn855") +metadata/_edit_lock_ = true + +[node name="target_position_fb" type="Label" parent="."] +layout_mode = 0 +offset_left = 65.0 +offset_top = 83.0 +offset_right = 105.0 +offset_bottom = 106.0 +label_settings = SubResource("LabelSettings_nn855") +metadata/_edit_lock_ = true diff --git a/scenes/ui/ui_viewport.tscn b/scenes/ui/ui_viewport.tscn index 02df564..2ed559d 100644 --- a/scenes/ui/ui_viewport.tscn +++ b/scenes/ui/ui_viewport.tscn @@ -8,7 +8,6 @@ offset_bottom = 40.0 script = ExtResource("1_2a424") [node name="sub_viewport" type="SubViewport" parent="."] -transparent_bg = true handle_input_locally = false render_target_update_mode = 4 diff --git a/scripts/controllers/cpu_system/cpu_controller.gd b/scripts/controllers/cpu_system/cpu_controller.gd index e5fdd47..e17cd3c 100644 --- a/scripts/controllers/cpu_system/cpu_controller.gd +++ b/scripts/controllers/cpu_system/cpu_controller.gd @@ -34,14 +34,66 @@ func assign_jet_target(jet: Jet) -> void: func process_jet_plan(jet: Jet) -> void: if not is_instance_valid(jet.target): return + var target_local_position: Vector3 = jet.to_local(jet.target.global_position) var target_direction: Vector3 = target_local_position.normalized() jet.target_ray.target_position = target_direction * 8 - jet.controller.cpu.yaw_left() + if maxf(target_direction.z, 0.0) == 0.0: + get_node("../../base_ui/target_position_fb").text = "infront" + jet.controller.cpu.no_action() + + if target_direction.x > 0.2: + jet.controller.cpu.yaw_right() + elif target_direction.x < -0.2: + jet.controller.cpu.yaw_left() + + elif maxf(target_direction.y, 0.5) == 0.5: + get_node("../../base_ui/target_position_ab").text = "above" + jet.controller.cpu.no_action() + + if target_direction.y > 0.2: + jet.controller.cpu.pitch_up() + elif target_direction.y < -0.2: + jet.controller.cpu.pitch_down() + + elif maxf(target_direction.y, -0.5) == -0.5: + get_node("../../base_ui/target_position_ab").text = "below" + jet.controller.cpu.no_action() + + if target_direction.y > 0.2: + jet.controller.cpu.yaw_right() + elif target_direction.y < -0.2: + jet.controller.cpu.yaw_left() + + else: + get_node("../../base_ui/target_position_fb").text = "behind" + jet.controller.cpu.no_action() + + if target_direction.x > 0.2: + jet.controller.cpu.yaw_right() + elif target_direction.x < -0.2: + jet.controller.cpu.yaw_left() + + + get_node("../../base_ui/target_z").text = str(target_direction.z) + get_node("../../base_ui/target_x").text = str(target_direction.x) + #var direction: Vector3 = ( #jet.target.global_position - jet.global_position #).normalized() -# + + + # NOTE: (From GPT) Mostly works but with precession nor do I really understand it... + #var forward_dot: float = target_direction.dot(Vector3.UP) + #if forward_dot >= cos(deg_to_rad(37.5)): + #get_node("../../base_ui/target_position_fb").text = "infront" + #jet.controller.cpu.no_action() + #else: + #get_node("../../base_ui/target_position_fb").text = "behind" + #if target_direction.x >= 0.2: + #jet.controller.cpu.yaw_right() + #elif target_direction.x <= -0.2: + #jet.controller.cpu.yaw_left()