feat: reducing ms gain from shotguns. Adjusting swarm launcher
This commit is contained in:
@@ -4,27 +4,39 @@ class_name HomingProjectile
|
||||
var weapon_source: Node
|
||||
var turn_speed: float = 5.0
|
||||
|
||||
var initial_aim_dir: Vector3 = Vector3.ZERO
|
||||
var cruise_speed: float = 60.0
|
||||
var ignition_timer: float = 0.5
|
||||
var ignited: bool = false
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_instance_valid(weapon_source) and weapon_source.get("homing_target_pos") != null:
|
||||
if not ignited:
|
||||
ignition_timer -= delta
|
||||
if ignition_timer <= 0.0:
|
||||
ignited = true
|
||||
drop_gravity = 0.0
|
||||
|
||||
if ignited and is_instance_valid(weapon_source):
|
||||
var target_dir: Vector3 = initial_aim_dir
|
||||
var is_painting = weapon_source.get("is_targeting")
|
||||
if is_painting != null and not is_painting:
|
||||
# Not painting target, just fly straight
|
||||
pass
|
||||
else:
|
||||
var target: Vector3 = weapon_source.homing_target_pos
|
||||
if target != Vector3.ZERO:
|
||||
# Steer towards target
|
||||
var speed = velocity.length()
|
||||
var desired_dir = (target - global_position).normalized()
|
||||
var current_dir = velocity.normalized()
|
||||
|
||||
if is_painting != null and is_painting:
|
||||
var target: Vector3 = weapon_source.get("homing_target_pos")
|
||||
if target != null and target != Vector3.ZERO:
|
||||
target_dir = (target - global_position).normalized()
|
||||
|
||||
var new_dir = current_dir.lerp(desired_dir, turn_speed * delta).normalized()
|
||||
velocity = new_dir * speed
|
||||
|
||||
# Also rotate visually to match new direction
|
||||
var up_vec = Vector3.UP
|
||||
if abs(new_dir.dot(up_vec)) > 0.99:
|
||||
up_vec = Vector3.RIGHT
|
||||
transform.basis = Basis.looking_at(new_dir, up_vec)
|
||||
if target_dir != Vector3.ZERO:
|
||||
var current_dir = velocity.normalized()
|
||||
var new_dir = current_dir.lerp(target_dir, turn_speed * delta).normalized()
|
||||
|
||||
# Accelerate to cruise speed
|
||||
var current_speed = velocity.length()
|
||||
var new_speed = move_toward(current_speed, cruise_speed, 80.0 * delta)
|
||||
velocity = new_dir * new_speed
|
||||
|
||||
var up_vec = Vector3.UP
|
||||
if abs(new_dir.dot(up_vec)) > 0.99:
|
||||
up_vec = Vector3.RIGHT
|
||||
transform.basis = Basis.looking_at(new_dir, up_vec)
|
||||
|
||||
super._physics_process(delta)
|
||||
|
||||
Reference in New Issue
Block a user