fixed y-wing turret laser trajectory. - Zerothelootrat
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -7,6 +7,7 @@ extends Area2D
|
||||
var speed = 100
|
||||
var target2 : Vector2
|
||||
var new_rot
|
||||
var direction
|
||||
func initialize(firing_solution,target):
|
||||
print('firing_solution='+str(firing_solution))
|
||||
new_rot = firing_solution
|
||||
@@ -18,6 +19,8 @@ func initialize(firing_solution,target):
|
||||
|
||||
func _ready():
|
||||
set_rotation(new_rot)
|
||||
direction = (target2 - global_position).normalized()
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
@@ -26,10 +29,27 @@ func _physics_process(delta):
|
||||
#print(target2)
|
||||
#print(typeof(global_position))
|
||||
#print(typeof(target))
|
||||
global_position -= (global_position - target2).normalized() * speed * delta
|
||||
#var direction = (global_position - target2).normalized()
|
||||
|
||||
#print("target2 " + str(target2))
|
||||
#print("direction normalized " + str(direction))
|
||||
#print("target_far " + str(target_far))
|
||||
#print("direction " + str(direction))
|
||||
#print("target2 " + str(target2))
|
||||
#global_position += (direction - global_position).normalized() * speed * delta
|
||||
global_position += direction * speed * delta
|
||||
if global_position.x >= 980:
|
||||
#print("cleanup")
|
||||
queue_free()
|
||||
|
||||
|
||||
|
||||
func _on_area_entered(area):
|
||||
if area is player:
|
||||
area.take_damage(1)
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_timer_timeout():
|
||||
print("cleanup")
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user