2026-10-30 23:08:47 -05:00
|
|
|
class_name TestWorld extends Node3D
|
|
|
|
|
|
|
|
|
|
|
2026-11-06 18:00:33 -06:00
|
|
|
@onready var jet: Node3D = $jet
|
|
|
|
|
@onready var jet2: Node3D = $jet2
|
|
|
|
|
var target_ray: RayCast3D
|
2026-11-05 20:47:05 -06:00
|
|
|
|
|
|
|
|
|
2026-11-06 18:00:33 -06:00
|
|
|
func _ready() -> void:
|
|
|
|
|
target_ray = jet.get_node("target_ray")
|
2026-11-05 20:47:05 -06:00
|
|
|
|
2026-11-06 18:00:33 -06:00
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
#test_dot_product(delta)
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func test_dot_product(_delta: float) -> void:
|
|
|
|
|
#NOTE: When using unit (normalized) vectors, the result will always be
|
|
|
|
|
# between -1.0 (180 degree angle) when the vectors are facing opposite
|
|
|
|
|
# directions, and 1.0 (0 degree angle) when the vectors are aligned.
|
|
|
|
|
var target_local_position: Vector3 = jet.to_local(jet2.global_position)
|
|
|
|
|
var target_direction: Vector3 = target_local_position.normalized()
|
|
|
|
|
target_ray.target_position = target_direction
|
|
|
|
|
var forward_dot: float = target_direction.dot(Vector3.UP)
|
|
|
|
|
var ud_dot: float = target_direction.dot(Vector3.FORWARD)
|
|
|
|
|
var lr_dot: float = target_direction.dot(Vector3.RIGHT)
|
|
|
|
|
|
|
|
|
|
#NOTE: if neg 'below'; if pos 'above'.
|
|
|
|
|
# Need window between +-0.2 or something for centered
|
|
|
|
|
print("Forward : ", forward_dot)
|
|
|
|
|
#print("Forward : ", rad_to_deg(cosh(forward_dot)))
|
|
|
|
|
|
|
|
|
|
#NOTE: if neg 'behind'; if pos 'ahead'.
|
|
|
|
|
# Need window between +-0.2 or something for centered
|
|
|
|
|
print("Up | Down : ", ud_dot)
|
|
|
|
|
#print("Up | Down : ", rad_to_deg(cosh(ud_dot)))
|
|
|
|
|
|
|
|
|
|
#NOTE: if neg 'left'; if pos 'right'.
|
|
|
|
|
# Need window between +-0.2 or something for centered
|
|
|
|
|
print("Left | Right : ", lr_dot)
|
|
|
|
|
#print("Left | Right : ", rad_to_deg(cosh(lr_dot)))
|