Y wing turret and laser update

This commit is contained in:
zerothelootrat
2024-06-05 17:37:46 -04:00
parent 781ccba218
commit 869ad92e5a
5 changed files with 37 additions and 17 deletions

View File

@@ -25,8 +25,8 @@ var main_cannon = true
#can turret fire? (rate of fire control)
var turret_cannon = true
var firing_solution = null
var target_area = null
var firing_solution : float
var target_area : Vector2
#reset raycast, setup settings
@@ -52,7 +52,10 @@ func _physics_process(delta):
if target_ray.is_colliding and target_ray.get_collider() is player:
if turret_cannon == true:
fire_turret(turret_muzzle,firing_solution,target_area)
fire_turret(turret_muzzle.global_position,firing_solution,target_area)
#print(str(turret_muzzle.global_position))
#print(str(firing_solution))
#print(str(target_area))
turret_timer.start()
turret_cannon = false
@@ -90,8 +93,11 @@ func aim_turret(delta):
firing_solution = atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180)
target_area = target_pos
func fire_turret(location,rotation,target_area):
get_tree().current_scene.firey_wingturret(location,rotation,target_area)
func fire_turret(location,firing_solution,target_area):
get_tree().current_scene.firey_wingturret(location,firing_solution,target_area)
#print(str(location))
#print(str(firing_solution))
#print(str(target_area))

View File

@@ -3,6 +3,7 @@ extends Area2D
@onready var turret_laser = $Sprite2D
var speed = 100
var target2 : Vector2
var new_rot
@@ -10,14 +11,14 @@ func initialize(firing_solution,target):
print('firing_solution='+str(firing_solution))
new_rot = firing_solution
#turret_laser.set_rotation(firing_solution)
print(str(turret_laser))
print(str(firing_solution))
#print(str(turret_laser))
#print(str(firing_solution))
target2 = target
#print(str(firing_solution))
func _ready():
turret_laser.set_rotation(new_rot)
$CollisionShape2D.set_rotation(new_rot)
set_rotation(new_rot)
func _physics_process(delta):
#print(str(global_position.x - target.x))
@@ -26,4 +27,9 @@ func _physics_process(delta):
#print(typeof(global_position))
#print(typeof(target))
global_position -= (global_position - target2).normalized() * speed * delta
pass
func _on_area_entered(area):
if area is player:
area.take_damage(1)
queue_free()