fixed y-wing turret laser trajectory. - Zerothelootrat

This commit is contained in:
zerothelootrat
2024-06-07 03:35:23 -04:00
parent 62f6b4d873
commit d2dc132952
5 changed files with 64 additions and 19 deletions

View File

@@ -49,6 +49,7 @@ func _physics_process(delta):
fire_main_cannon()
main_cannon = false
mainCannonFire.start()
aim_turret(delta)
if target_ray.is_colliding and target_ray.get_collider() is player:
@@ -69,19 +70,31 @@ func _physics_process(delta):
#turret.rotate(current_rotation)
#turret.rotation(atan2(target.x - turret_pos.x,target.y - turret_pos.y))
var default_target : Vector2
#figured out with loki, holy shit this was annoying
func aim_turret(delta):
var target : Vector2 = get_tree().current_scene.player.global_position
var turret_pos = turret.global_position
var target_rot = atan2(target.x - turret_pos.x, target.y - turret_pos.y)
var target_pos = get_tree().current_scene.player.global_position
var current_rotation = turret.rotation
var player = get_tree().current_scene.player
if is_instance_valid(player):
var target = get_tree().current_scene.player.global_position
var turret_pos = turret.global_position
var target_rot = atan2(target.x - turret_pos.x, target.y - turret_pos.y)
var target_pos = get_tree().current_scene.player.global_position
var current_rotation = turret.rotation
if target == null:
firing_solution = 0
if target == null:
default_target.x = 0
default_target.y = 0
target = default_target
var speed = 5 #in degrees, can adjust
var direction = 1
if target_rot < current_rotation: #may need to be "<"
direction = -1
var speed = 5 #in degrees, can adjust
var direction = 1
if target_rot < current_rotation: #may need to be "<"
direction = -1
#current_rotation += direction * speed * (PI/180) * delta
#turret.look_at(target_pos)
@@ -90,9 +103,9 @@ func aim_turret(delta):
#current_rotation += current_rotation * 0.90 + target_rot * 0.10
#turret.set_rotation(atan2(target.x - turret_pos.x,target.y - turret_pos.y))
#turret.set_rotation(atan2(turret_pos.x - target.x, turret_pos.y - target_pos.y))
turret.set_rotation(atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180))
firing_solution = atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180)
target_area = target_pos
turret.set_rotation(atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180))
firing_solution = atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180)
target_area = target_pos
func fire_turret(location,firing_solution,target_area):
get_tree().current_scene.firey_wingturret(location,firing_solution,target_area)