I am now creating an omni-directional shooter
I would like to implement a homing laser to hit the enemy, but due to the player's rotation, the laser does not fly in the intended direction because it is out of alignment with the original position of the enemy.
I tried to find a method in Vector2 that would give a good result, but it did not work.
Is there any good way or formula to do this?
Or is there a formula for this?
source code
var h = load("res://Graphics/Bom/Horming.tscn")
var h_instance = h.instance()
print(h_instance)
var speed = 1000
var angle = -90 + rand_range(-45, 45)
add_child(h_instance)
while len(enemy_list) > 0:
var enemy = enemy_list.pop_front()
print(enemy)
var enemy_direction = Vector2(cos(self.rotation_degrees), sin(self.rotation_degrees))
for j in range(0, 32):
yield(get_tree().create_timer(0.5), "timeout")
h_instance.start(speed, angle, Vector2.ZERO, enemy.position.rotated())