Cleaned up notes; restructured test scene plus cpu controller script; added WIP action stack logic
This commit is contained in:
@@ -34,67 +34,77 @@ func assign_jet_target(jet: Jet) -> void:
|
||||
|
||||
func assign_jet_action(jet: Jet) -> void:
|
||||
jet.strategy_stack.add_child( MoveTowards.new() )
|
||||
jet.strategy_stack.add_child( RollLeftSideUp.new() )
|
||||
|
||||
func process_jet_plan(jet: Jet) -> void:
|
||||
jet.strategy_stack.process_action(jet)
|
||||
|
||||
|
||||
|
||||
#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:
|
||||
#jet.controller.cpu.no_action()
|
||||
#
|
||||
#if target_direction.y > 0.2:
|
||||
#get_node("../../base_ui/target_position_ab").text = "above"
|
||||
#jet.controller.cpu.pitch_up()
|
||||
#elif target_direction.y < -0.2:
|
||||
#get_node("../../base_ui/target_position_ab").text = "below"
|
||||
#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)
|
||||
#process_jet_plan_old(jet)
|
||||
#process_jet_plan_gpt(jet)
|
||||
#jet.strategy_stack.process_action(jet)
|
||||
|
||||
var target_local_position: Vector3 = jet.to_local(jet.target.global_position)
|
||||
var target_direction: Vector3 = target_local_position.normalized()
|
||||
jet.target_direction = target_direction
|
||||
|
||||
|
||||
func process_jet_plan_old(jet: Jet) -> void:
|
||||
#var direction: Vector3 = (
|
||||
#jet.target.global_position - jet.global_position
|
||||
#).normalized()
|
||||
|
||||
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
|
||||
|
||||
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:
|
||||
jet.controller.cpu.no_action()
|
||||
|
||||
if target_direction.y > 0.2:
|
||||
get_node("../../base_ui/target_position_ab").text = "above"
|
||||
jet.controller.cpu.pitch_up()
|
||||
elif target_direction.y < -0.2:
|
||||
get_node("../../base_ui/target_position_ab").text = "below"
|
||||
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)
|
||||
|
||||
func process_jet_plan_gpt(jet: Jet) -> void:
|
||||
# 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()
|
||||
var target_direction: Vector3 = jet.to_local(jet.target.global_position)
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user