I'm currently trying to code for a boss attack which uses a parabolic equation to calculate the trajectory of the boss' projectiles. The function works perfectly when the player is at or below the y origin of the attack, but when the player is at a higher y level than the origin of the attack the parabola it calculates goes over the player's head every time. I'm probably not understanding some component of how to solve for the equation. This is my code below:
burp_h = 0
burp_k = 0
burp_a = 0
var inaccuracy_x = rng.randi_range(-LOOGIE_INACCURACY_MAX, LOOGIE_INACCURACY_MAX)
var inaccuracy_y = rng.randi_range(-LOOGIE_INACCURACY_MAX, LOOGIE_INACCURACY_MAX)
var target_x = last_player_position.x + inaccuracy_x
var target_y = last_player_position.y + inaccuracy_y
#Find the h in the parabola formula by dividing the distance between player
#and ent mouth by 2 (axis of symmetry)
burp_h = (burp_origin.global_position.x - target_x)/2.0
#Find the two constants to multiply a by to find a
var c1 = pow(target_x - burp_h, 2)
var c2 = pow(burp_origin.global_position.x - burp_h, 2)
if target_y >= burp_origin.global_position.y:
#Find the difference between player and mouth y for linear system
var y_difference = burp_origin.global_position.y - target_y
#Subtract c2 from c1 to find the difference between constants and eliminate k
var c = c2 - c1
#Find a by dividing y-difference by c, then find k
burp_a = -y_difference/c
burp_k = burp_origin.global_position.y - (c2 * burp_a)
else:
#Find the difference between player and mouth y for linear system
var y_difference = target_y - burp_origin.global_position.y\
#Subtract c2 from c1 to find the difference between constants and eliminate k
var c = c1 - c2
#Find a by dividing y-difference by c, then find k
burp_a = y_difference/c
burp_k = target_y - (c1 * burp_a)
Basically, I am using the vertex form of the parabola and solving the linear system to find the different variables (h, k, and a).
I changed how I was solving the equation for when the player is at a higher y level than the origin point (because previously the parabola either curved in the wrong direction or the attack started at too high of a y level when I was just reversing the sign of a).
To me it appears as though the axis of symmetry is not being calculated correctly when the player is at a higher y.


Any help would be greatly appreciated.