added skunk works folder; added sub viewport ui option; wip testing logic
This commit is contained in:
@@ -16,9 +16,6 @@ func _controller_message(event: BaseEvent) -> void:
|
||||
|
||||
func handle_init_spawns_loaded_event() -> void:
|
||||
for jet: Jet in jets_collection.get_children():
|
||||
if Globals.ControlMode.PLAYER_MODE == jet.controller.control_mode:
|
||||
continue
|
||||
|
||||
create_jet_plan(jet)
|
||||
|
||||
func create_jet_plan(jet: Jet) -> void:
|
||||
@@ -37,56 +34,14 @@ func assign_jet_target(jet: Jet) -> void:
|
||||
func process_jet_plan(jet: Jet) -> void:
|
||||
if not is_instance_valid(jet.target): return
|
||||
|
||||
var direction: Vector3 = (
|
||||
jet.target.global_position - jet.global_position
|
||||
).normalized()
|
||||
|
||||
var target_basis = Basis.looking_at(direction, Vector3.UP)
|
||||
var target_rotation = target_basis.get_euler()
|
||||
var current_rotation = jet.global_rotation
|
||||
|
||||
var yaw_error = wrapf(
|
||||
target_rotation.y - current_rotation.y,
|
||||
-PI,
|
||||
PI
|
||||
)
|
||||
|
||||
var pitch_error = wrapf(
|
||||
target_rotation.x - current_rotation.x,
|
||||
-PI,
|
||||
PI
|
||||
)
|
||||
|
||||
var deadzone = deg_to_rad(2.0)
|
||||
|
||||
if yaw_error > deadzone:
|
||||
jet.controller.cpu.yaw_right()
|
||||
elif yaw_error < -deadzone:
|
||||
jet.controller.cpu.yaw_left()
|
||||
else:
|
||||
jet.controller.cpu.no_action()
|
||||
|
||||
if pitch_error > deadzone:
|
||||
jet.controller.cpu.pitch_down()
|
||||
elif pitch_error < -deadzone:
|
||||
jet.controller.cpu.pitch_up()
|
||||
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()
|
||||
|
||||
|
||||
|
||||
#func process_jet_plan(jet: Jet) -> void:
|
||||
#var direction = (jet.target.global_position - jet.global_position).normalized()
|
||||
#var target_basis = jet.looking_at(direction, Vector3.UP)
|
||||
#var target_rotation = target_basis.get_euler()
|
||||
|
||||
|
||||
#var direction = jet.target.global_position - jet.global_position
|
||||
#var desired_rotation = jet.look_rotation(direction)
|
||||
|
||||
#var rotation_error = desired_rotation - jet.rotation
|
||||
|
||||
#jet.pitch_input = calculate_pitch(rotation_error)
|
||||
#jet.yaw_input = calculate_yaw(rotation_error)
|
||||
#jet.roll_input = calculate_roll(rotation_error)
|
||||
#jet.throttle = calculate_throttle(distance)
|
||||
#var direction: Vector3 = (
|
||||
#jet.target.global_position - jet.global_position
|
||||
#).normalized()
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user