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

@@ -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()